LeadAPIValidationUtilOOB - Scoped
The LeadAPIValidationUtilOOB script include provides methods that are called by the lead REST API to validate lead records and associated lead line item records when they are created (POST) or updated (PATCH).
If you want to customize how lead records are validated when the lead API methods are called, override the methods in this script include in the LeadAPIValidationUtil script include. The names of the methods that you are overriding in the LeadAPIValidationUtil script include must be the same as those in the LeadAPIValidationUtilOOB script include file.
This API is provided within the sn_lead_mgmt_core namespace. To access the API, the Lead Management Data Model (sn_lead_mgmt_core) plugin must be activated on the instance, and the calling
user must have the sn_lead_mgmt_core.lead_integrator role.
For additional information on Lead Management, see Using Lead Management.
LeadAPIValidationUtilOOB - validateLeadObjectForPatchCall (Object leadObject)
Validates the passed fields for a specified lead and its associated line items when updating a lead record using the PATCH endpoint of the lead API.
- Checks for mandatory fields
- Checks that the phone number and email address have the proper format.
- Checks choice and reference fields, ignoring any invalid values.
- Validates the stage and throws an error if the user attempts to qualify a lead.
| Name | Type | Description |
|---|---|---|
| leadObject | Object | Fields to update in the specified lead record and associated lead line item records. For a list of the fields that can be passed and their associated requirements, see lead - PATCH /sn_lead_mgmt_core/lead/{sys_id}. |
| Type | Description |
|---|---|
| <JSON object> | Results of the validation. |
| <JSON object>.errors | Details of the errors detected while validating the passed lead and lead line item object. Returns an empty array if no errors are detected. For example: These error messages are located in the LeadAPIConstantsOOB script include. Data type: Array of Objects |
| <JSON object>.indexesOfleadLineItemsForInsertion | Indexes of new lead line items that need to be inserted in the leadObject. Data type: Array of Integers |
The following code example shows where to add your custom code for the validateLeadObjectForPatchCall() method in the LeadAPIValidationUtil script include.
var LeadAPIValidationUtil = Class.create();
LeadAPIValidationUtil.prototype = Object.extendsObject(LeadAPIValidationUtilOOB, {
// Define overriding functions here
validateLeadObjectForPatchCall: function(leadObject) {
// Add your custom code here
},
type: 'LeadAPIValidationUtil'
});
LeadAPIValidationUtilOOB - validateLeadObjectForPostCall (Object leadObject)
Validates the passed fields for a specified lead and its associated line items when creating a lead record using the POST endpoint of the lead API.
- Checks for required fields.
- Checks that the phone number and email address have the proper format.
- Checks choice and reference fields, ignoring any invalid values.
| Name | Type | Description |
|---|---|---|
| leadObject | Object | Fields to insert in the new lead record and associated lead line item records. For a list of the fields that can be passed and their associated requirements, see lead - POST /sn_lead_mgmt_core/lead. |
| Type | Description |
|---|---|
| Array | Details of the errors detected while validating the passed lead and lead line item object. Returns an empty array if no errors are detected. For example: These error messages are located in the LeadAPIConstantsOOB script include. |
The following code example shows where to add your custom code for the validateLeadObjectForPostCall() method in the LeadAPIValidationUtil script include.
var LeadAPIValidationUtil = Class.create();
LeadAPIValidationUtil.prototype = Object.extendsObject(LeadAPIValidationUtilOOB, {
// Define overriding functions here
validateLeadObjectForPostCall: function(leadObject) {
// Add your custom code
},
type: 'LeadAPIValidationUtil'
});