Identify the records on which you want to run the OFAC Check.
Create Request Wrapper using the below Attributes:-
String sIndividualName = oAccount.FirstName + ' ' + oAccount.LastName; oReqWrapper.sFirstName = oAccount.FirstName; oReqWrapper.sLastName = oAccount.LastName; oReqWrapper.sType = sType; System.debug('oReqWrapper.sType :::>'+oReqWrapper.sType); oReqWrapper.sName = sIndividualName; System.debug('oReqWrapper.sName :::>'+oReqWrapper.sName); oReqWrapper.sParentRecordId = oAccount.Id; //oReqWrapper.sCountryCode = 'United States';
- After this, you need to store the response which you will get
Code Block creditchecker.WSOFACScreeningService.OFACRequestWrapper oReqWrapper = new creditchecker.WSOFACScreeningService.OFACRequestWrapper(); oReqWrapper.sFirstName = <First Name in case of Individual Search>; oReqWrapper.sLastName = <Last Name in case of Individual Search>; oReqWrapper.sType = <Individual or Entity>; oReqWrapper.sName = <Individual Name or Entity Name depending on the type of Search>; oReqWrapper.sEntityName = <Entity Name in case of Entity Search>; oReqWrapper.sParentRecordId = <Parent Id of the Record to which youw ant to Link the OFAC Record>
Pass the Request Wrapper to the API call which will return a Response Wrapper
Code Block creditchecker.WSOFACScreeningService.OFACResponseWrapper oResponseWrapper = creditchecker.WSOFACScreeningService.callOFACService(oReqWrapper);
At last, you need to call our Below Apis to get the result:-Store the OFAC Results inside Salesforce
Code Block creditchecker.Utility.storeOFACData(oResponseWrapper.oOFAC, oResponseWrapper.listOFACResults); creditchecker.Utility.populateOFACMatchResults(new Set<Id>{oResponseWrapper.oOFAC.Id});
*Please note the above can be bulkified as well. You can get the list of OFAC Response Wrappers and store them in bulk. *The same code will work in Batch as well in Triggers.