API Version
68.0
Requires Chatter
No
Signature
public static ConnectApi.InsAttributeValidationRepresentation validateAttributes(ConnectApi.InsAttributeValidationInputRepresentation insAttributeValidationInputRepresentation)
Parameters
- insAttributeValidationInputRepresentation
- Type: ConnectApi.InsAttributeValidationInputRepresentation
- Required. List of attribute definitions to validate. Identify each attribute by ID, code, or developer name. The method confirms that each definition exists in the org and is active, and returns resolution guidance for any attribute that can't be validated. Specify a context definition ID when you need to resolve dynamic context attributes.
Return Value
Usage
Use this method at design time to confirm that attribute definitions referenced in a product model, constraint model, or request payload exist in the org and are active. You can directly call this method or use this method from the Insurance Design Advisor agent to check the validity of the attribute definitions, before the attribute definitions are used.
For each attribute lookup, the method checks that at least one of attributeId, attributeCode, or attributeName is provided, that an AttributeDefinition record exists, and that the record is active (IsActive is true). Lookups are resolved by attribute ID, then attribute code, and then developer name.
Each result sets isValid to true when the attribute definition is valid. When the attribute is invalid, instructions contains the resolution guidance. Per-attribute failures use these error codes:
- SF-INS-DSAV-00030 — the attribute definition wasn't found.
- SF-INS-DSAV-00031 — the attribute definition is inactive.
- SF-INS-DSAV-00032 — the lookup didn't include an attribute ID, code, or developer name.
The method resolves lookups in bulk. Regardless of how many attributes you specify, the method issues at most three queries, one for each identifier type, and then matches every lookup in memory against those results.
Example
This is a sample code to validate an attribute definition from Apex.
ConnectApi.InsAttributeInputRepresentation attr =
new ConnectApi.InsAttributeInputRepresentation();
attr.attributeName = 'Limit';
ConnectApi.InsAttributeValidationInputRepresentation input =
new ConnectApi.InsAttributeValidationInputRepresentation();
input.attributeLookups = new List<ConnectApi.InsAttributeInputRepresentation>{ attr };
ConnectApi.InsAttributeValidationRepresentation result =
ConnectApi.InsuranceDesignAdvisorFamily.validateAttributes(input);
System.debug('isValid=' + result.isValid);
System.debug('attributes=' + result.attributes);
System.debug('errors=' + result.errors);