Validate a record by its ID
validateRecord validates configured address, phone, and email fields for a Salesforce record ID, saves results on the record, and returns per-field statuses with optional auto-processing scenarios.
On this page
The validateRecord method validates a Salesforce record by its ID and saves the results on the record. Plauti Verify reads the record itself, validates every address, phone and email field configured for the object in the Verify setup, and saves the statuses the same way the "Plauti Verify - Validate All" flow action does.
You don't need saveValidationResult with this method, because the results are already saved. To validate values that are not stored on a record, use the bulk validation methods instead.
Key Points
- Accepts a
RecordValidationInput_v1object with the record ID and, optionally, an auto-processing scenario name per service (address, phone, email). - Queries the record itself, so every configured field is included. You don't need to query the record or pass field values.
- Validates all configured fields that have a value in one callout, then updates the record with the results.
- Field values are not changed unless you name an auto-processing scenario. The scenario is applied to all fields of that service, for example to accept address suggestions.
- Returns a
RecordValidationOutput_v1object with the record's new status and anAddressValidationOutput_v1,PhoneValidationOutput_v1orEmailValidationOutput_v1per field, keyed by field API name. - Invalid input is rejected before the callout, so it doesn't use credits.
Method Signature
Method name: validateRecord
global recordval.RecordValidationOutput_v1 validateRecord(recordval.RecordValidationInput_v1 input)Parameters
| Type | Variable | Description |
|---|---|---|
| RecordValidationInput_v1 | input |
The structured input object containing the ID of the record to validate and, optionally, the auto-processing scenarios to apply. |
Input
RecordValidationInput_v1
| Field | Type | Required | Description |
|---|---|---|---|
recordId |
Id | Yes | The ID of the record to validate. The record's object must be configured in the Verify setup. |
addressScenarioName |
String | No | The name of an address auto-processing scenario. It is applied to all validated address fields of the record. |
phoneScenarioName |
String | No | The name of a phone auto-processing scenario. It is applied to all validated phone fields of the record. |
emailScenarioName |
String | No | The name of an email auto-processing scenario. It is applied to all validated email fields of the record. |
For a service without a scenario name, only the validation statuses of its fields are saved.
Which fields are validated
Plauti Verify uses the object's configuration in the Verify setup:
- Address: validated when the street field and the country field have a value. When State and Country/Territory Picklists are enabled, the country code field must have a value as well.
- Phone: validated when the phone field has a value. The phone country and format configured for the field are used.
- Email: validated when the email field has a value.
Fields without a value are skipped.
What is saved on the record
The results are saved with one update of the record:
- For each validated field: its validation result and, when they are configured in the Verify setup, its status code, status message, and status date and time fields, plus the phone type field for phone fields.
- The record's Plauti Verify status.
- With a scenario name: the field values the scenario changes, for example an accepted address suggestion or a formatted phone number.
Fields that were not validated in this call keep their earlier status, and that status is included when the record's status is determined.
The update is a regular record update, so your validation rules, triggers and flows on the object run as usual. Plauti Verify itself does not validate the record again on this update. The running user must have edit access to the record.
Callouts and DML
validateRecord makes a callout to the validation service and then updates the record. Salesforce does not allow a callout after uncommitted DML in the same transaction, so:
- Call
validateRecordbefore any DML in the transaction. If there is uncommitted work, the method throws arecordval.APICallExceptionand nothing is saved. - Callouts are not allowed directly from a trigger. To validate records from a trigger, call
validateRecordfrom an asynchronous context, such as a@future(callout=true)method or a Queueable that implementsDatabase.AllowsCallouts. See Validate changed fields from a trigger for this pattern.
Output
Return Type: RecordValidationOutput_v1
| Field | Type | Description |
|---|---|---|
recordId |
Id | The ID of the validated record. |
recordStatus |
String | The Plauti Verify status saved on the record, for example GREEN, AMBER or RED. It is CHANGED or MANUAL when another field on the record was changed or entered manually after its last validation. |
status |
recordval.Status_v1 | The status of the validation as a whole. Code 850 means the validation was processed. Each field result carries its own status and advice (Advice_v1). |
addresses |
Map<String, recordval.AddressValidationOutput_v1> |
The address results, keyed by the API name of the address's street field, for example MailingStreet. See AddressValidationOutput_v1. |
phones |
Map<String, recordval.PhoneValidationOutput_v1> |
The phone results, keyed by the API name of the phone field, for example MobilePhone. See PhoneValidationOutput_v1. |
emails |
Map<String, recordval.EmailValidationOutput_v1> |
The email results, keyed by the API name of the email field, for example Email. See EmailValidationOutput_v1. |
The maps are never null. They are empty for a service with no validated fields.
The results show what the validation service returned. When a scenario changes field values, query the record to see the values that were saved.
Exceptions
| Exception | Cause |
|---|---|
recordval.IllegalApiArgumentException |
The input or its recordId is null, a scenario name does not match an auto-processing scenario for that service, the record's object is not configured in the Verify setup, or the record does not exist or is not visible to the running user. |
recordval.APICallException |
The validation service could not be reached or returned an error, or the transaction has uncommitted DML. The error is in the message field; errorCode holds the status code when the validation service returned one. Nothing is saved on the record. |
Other exceptions, such as a DmlException when a validation rule blocks the update, are passed on to the caller.
Apex Example
This Apex code validates a Lead by its ID, applies the Default Phone auto-processing scenario to its phone fields, and logs the record's new status and the result per field.
// Ask for a Lead ID
String leadId = '00QAa00000JinjeMAB'; // Replace with actual Lead ID
// Initialize the Record Validation API
recordval.RecordValidationAPI_v1 api = new recordval.RecordValidationAPI_v1();
// Prepare the record validation input
recordval.RecordValidationInput_v1 input = new recordval.RecordValidationInput_v1();
input.recordId = leadId;
input.phoneScenarioName = 'Default Phone'; // Optional: also apply a phone auto-processing scenario
// Validate the record and save the results on it
recordval.RecordValidationOutput_v1 output;
try {
output = api.validateRecord(input);
} catch (recordval.IllegalApiArgumentException e) {
System.debug('Invalid input: ' + e.getMessage());
return;
} catch (recordval.APICallException e) {
System.debug('Record validation failed: ' + e.message);
return;
}
// Log the record status and the results, per field
System.debug('Record status: ' + output.recordStatus);
for (String fieldName : output.addresses.keySet()) {
recordval.AddressValidationOutput_v1 result = output.addresses.get(fieldName);
System.debug(fieldName + ': ' + result.getAdvice() + ' (' + result.status.code + ' ' + result.status.message + ')');
}
for (String fieldName : output.phones.keySet()) {
recordval.PhoneValidationOutput_v1 result = output.phones.get(fieldName);
System.debug(fieldName + ': ' + result.phoneNumber + ' ' + result.getPhoneType() + ' ' + result.getAdvice());
}
for (String fieldName : output.emails.keySet()) {
recordval.EmailValidationOutput_v1 result = output.emails.get(fieldName);
System.debug(fieldName + ': ' + result.getAdvice() + ' (' + result.status.code + ' ' + result.status.message + ')');
}