Identify the records on which you want to run the OFAC Check.
Create Request Wrapper using the below Attributes:-
After this, you need to store the response which you will getCode Block String sIndividualNamecreditchecker.WSOFACScreeningService.OFACRequestWrapper oReqWrapper = oAccount.FirstName + ' ' + oAccount.LastName;new creditchecker.WSOFACScreeningService.OFACRequestWrapper(); oReqWrapper.sFirstName = oAccount.FirstName <First Name in case of Individual Search>; oReqWrapper.sLastName = oAccount.LastName <Last Name in case of Individual Search>; oReqWrapper.sType = <Individual or sTypeEntity>; System.debug('oReqWrapper.sType :::>'+oReqWrapper.sType); oReqWrapper.sName = sIndividualName; System.debug('oReqWrapper.sName :::>'+oReqWrapper.sName); 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 oAccount.Id; //oReqWrapper.sCountryCode = 'United States';
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.