API Version
68.0
Requires Chatter
No
Signature
public static ConnectApi.InsProductModelValidationRepresentation validateProductModel(ConnectApi.InsProductModelValidationInputRepresentation insProductModelValidationInputRepresentation)
Parameters
- insProductModelValidationInputRepresentation
- Type: ConnectApi.InsProductModelValidationInputRepresentation
- Required. Input that identifies the root insurance product whose model setup should be validated. The method validates this product and all associated products in its hierarchy, including direct children, component groups, and classification-based children.
Return Value
Usage
Use this method at design time to validate a root insurance product and every associated product in its hierarchy, including direct children, component groups, and classification-based children. The method checks configuration that would otherwise surface as runtime failures during quoting, rating, or policy issuance.
Validations include confirming that each product is active; that the product code is specified, is a single word, and is unique; that an active record type and product specification record type mapping are present; that root-level product type is Base, Bundle, or Set; that BasedOnId points to a valid product classification; that an active product selling model and price book entry are associated; that attribute definitions have non-blank developer names and unique codes; that extended attribute reference object and field are set together and resolve in metadata; that the root product is associated with a catalog category; and that the hierarchy has no cycles or forbidden parent-child specification-type pairings.
When every product in the hierarchy passes validation, isValid is true. When one or more products fail, isValid is false and products lists the related products that have configuration errors. Examples of per-product error codes include:
- SF-INS-DSAV-00001 — the product isn’t active.
- SF-INS-DSAV-00004 — the product isn’t associated with a product selling model option.
- SF-INS-DSAV-00011 — the product doesn’t have a price book entry.
- SF-INS-DSAV-00014 — the product doesn’t have a record type assigned.
- SF-INS-DSAV-00027 — the product hierarchy contains a circular reference.
Top-level errors are returned in errors when the request can’t be validated per product. A missing productId returns SF-INS-DSAV-00013. A blank, malformed, or invalid Product2 ID returns SF-INS-DSAV-00012. Insufficient access, or Digital Insurance not enabled for the org, returns INSUFFICIENT_ACCESS.
Example
This sample validates a product model from Apex.
ConnectApi.InsProductModelValidationInputRepresentation input =
new ConnectApi.InsProductModelValidationInputRepresentation();
input.productId = '01txx0000006i3DAAQ';
ConnectApi.InsProductModelValidationRepresentation result =
ConnectApi.InsuranceDesignAdvisorFamily.validateProductModel(input);
System.debug('isValid=' + result.isValid);
System.debug('productId=' + result.productId);
System.debug('products=' + result.products);
System.debug('errors=' + result.errors);
System.debug('infos=' + result.infos);