Map phoneValidationStatusMap = new Map { 'Number format validated and number verified' => 'Verified', 'Invalid number format supplied' => 'Unverified', 'Valid number format but not verified with network lookup' => 'Unknown', 'Number format validated and number verified via network lookup but not currently available (i.e. phone off, out of range)' => 'Absent', 'Valid number but not active on a network' => 'Teleservice not provisioned', 'Number has been blocked from lookups' => 'Unknown' }; Map emailValidationStatusMap = new Map { 'Mailbox exists, is reachable, and not known to be illegitimate or disposable.' => 'verified', 'Domain is administered by a disposable email provider.' => 'disposable', 'Domain has no reachable mail exchangers.' => 'unreachable', 'Seed, spamtrap, black hole, technical role account or inactive domain.' => 'illegitimate', 'Mailbox or domain does not exist, or mailbox is full, suspended or disabled.' => 'undeliverable', 'We were unable to conclusively verify or invalidate this address.' => 'unknown' }; Map addressValidationStatusMap = new Map { 'Validation Pending!' => 'ManuallyUpdated', 'Validation Pending' => 'ManuallyUpdated', 'Verified by Experian QAS!' => 'AddressVerified', 'Verified by Experian!' => 'AddressVerified', 'Verified by Experian QAS' => 'AddressVerified', 'Verified by Experian' => 'AddressVerified', 'User Preferred' => 'AddressUnverified', 'User Preferred!' => 'AddressUnverified', 'Could not be Verified!' => 'AddressUnverified', 'Could not be Verified' => 'AddressUnverified', 'Unknown' => 'ManuallyUpdated', 'Unknown!' => 'ManuallyUpdated' }; String recordId = '0000000'; Account record = [ SELECT BillingStreet, BillingState, BillingPostalCode, BillingCountry, Billing_Address_Validation_Status__c, Billing_Address_Validation_Timestamp__c, Phone, Phone_Validation_Status__c, Phone_Validation_Timestamp__c, PersonEmail, Person_Email_Validation_Status__c, Person_Email_Validation_Timestamp__c FROM Account WHERE Id = :recordId ]; TExperianLEDQ__LEDQ_TransactionLog__c[] allTlogs = new List(); // Example for address field String fieldApiName = 'BillingStreet'; String type = 'Address'; List inputValueArr = new List{record.BillingStreet, record.BillingState, record.BillingPostalCode, record.BillingCountry}; String inputValue = String.join(inputValueArr, ','); String inputValueAsBase64 = EncodingUtil.base64Encode(Blob.valueOf(inputValue)); String status = addressValidationStatusMap.get(record.Billing_Address_Validation_Status__c); String errorMessage = ''; DateTime timestamp = record.Billing_Address_Validation_Timestamp__c; // This assumes the timestamp field is in a date format. String timestamps will need to be converted. TExperianLEDQ__LEDQ_TransactionLog__c tlogAddress = new TExperianLEDQ__LEDQ_TransactionLog__c(); // The record ID of the associated record tlogAddress.LEDQ_RecordId__c = recordId; // The API name of the validated field. Use the street subfield for addresses, e.g. BillingStreet tlogAddress.LEDQ_FieldAPIName__c = fieldApiName; // The validation type, in title case. Address|Email|Phone tlogAddress.LEDQ_Type__c = type; // The unique base64 identifier for the field value(s). See above for details. tlogAddress.LEDQ_InputValue__c = inputValueAsBase64; // The status of the transaction log. tlogAddress.LEDQ_Status__c = status; // Details of an encountered error, if applicable. For example, an API failure tlogAddress.LEDQ_ErrorMessage__c = errorMessage; // The timestamp to be associated with this transaction log tlogAddress.LEDQ_TimeStamp__c = timestamp; allTlogs.add(tlogAddress); //Example for phone field fieldApiName = 'Phone'; type = 'Phone'; inputValue = EncodingUtil.base64Encode(Blob.valueOf(record.Phone)); status = phoneValidationStatusMap.get(record.Phone_Validation_Status__c); errorMessage = ''; timestamp = record.Phone_Validation_Timestamp__c; // This assumes the timestamp field is in a date format. String timestamps will need to be converted. TExperianLEDQ__LEDQ_TransactionLog__c tlogPhone = new TExperianLEDQ__LEDQ_TransactionLog__c(); // The record ID of the associated record tlogPhone.LEDQ_RecordId__c = recordId; // The API name of the validated field. Use the street subfield for addresses, e.g. BillingStreet tlogPhone.LEDQ_FieldAPIName__c = fieldApiName; // The validation type, in title case. Address|Email|Phone tlogPhone.LEDQ_Type__c = type; // The field value that was validated tlogPhone.LEDQ_InputValue__c = inputValue; // The status of the transaction log. tlogPhone.LEDQ_Status__c = status; // Details of an encountered error, if applicable. For example, an API failure tlogPhone.LEDQ_ErrorMessage__c = errorMessage; // The timestamp to be associated with this transaction log tlogPhone.LEDQ_TimeStamp__c = timestamp; allTlogs.add(tlogPhone); //Example for email field fieldApiName = 'PersonEmail'; type = 'Email'; inputValue = EncodingUtil.base64Encode(Blob.valueOf(record.PersonEmail)); status = emailValidationStatusMap.get(record.Person_Email_Validation_Status__c); errorMessage = ''; timestamp = record.Person_Email_Validation_Timestamp__c; // This assumes the timestamp field is in a date format. String timestamps will need to be converted. TExperianLEDQ__LEDQ_TransactionLog__c tlogEmail = new TExperianLEDQ__LEDQ_TransactionLog__c(); // The record ID of the associated record tlogEmail.LEDQ_RecordId__c = recordId; // The API name of the validated field. Use the street subfield for addresses, e.g. BillingStreet tlogEmail.LEDQ_FieldAPIName__c = fieldApiName; // The validation type, in title case. Address|Email|Phone tlogEmail.LEDQ_Type__c = type; // The field value that was validated tlogEmail.LEDQ_InputValue__c = inputValue; // The status of the transaction log. tlogEmail.LEDQ_Status__c = status; // Details of an encountered error, if applicable. For example, an API failure tlogEmail.LEDQ_ErrorMessage__c = errorMessage; // The timestamp to be associated with this transaction log tlogEmail.LEDQ_TimeStamp__c = timestamp; allTlogs.add(tlogEmail); // Commit transaction log list to DB upsert allTlogs;