Friday, September 1, 2023

#985 Data Sync Strategies with the OIC SFDC Adapter

Back to the use case from the previous post - syncing users between SFDC and downstream apps. There are multiple approaches to getting the users from SFDC.


Scheduled Integration

This approach is useful if the business use case allows for changed user data to be collected on a regular basis. This could be daily, hourly etc. i.e. not real time.

1. Scheduled job using SOQL to retrieve users that have been changed since the last run. The field - LastModifiedDate - can be used or even the SOQL SystemModStamp field e.g. 

SELECT AboutMe, AccountId,Alias, BadgeText, BannerPhotoUrl, CallCenterId, City, CommunityNickname, CompanyName, ContactId, Country, Department,Division,Email, EmailEncodingKey, EmployeeNumber,Extension,Fax, FirstName,IndividualId,IsActive,  LanguageLocaleKey,LastLoginDate, LastName, ManagerId, MobilePhone, Phone, PostalCode, ProfileId,SenderEmail, SenderName, Signature, State,Street,Title, Username, UserRoleId, UserType, LastModifiedDate  
FROM USER
WHERE SystemModStamp >= LAST_N_DAYS:1

LAST_N_DAYS:1 - gives me any changes from yesterday.

I test this query in the adapter wizard - only Julius Martov, the user I was working on yesterday is returned.


I can, of course, add an integration parameter - 


and use this in the query - 














SOQL is - 

SELECT AboutMe, AccountId,Alias, BadgeText, BannerPhotoUrl, CallCenterId, City, CommunityNickname, CompanyName, ContactId, Country, Department,Division,Email, EmailEncodingKey, EmployeeNumber,Extension,Fax, FirstName,IndividualId,IsActive,  LanguageLocaleKey,LastLoginDate, LastName, ManagerId, MobilePhone, Phone, PostalCode, ProfileId,SenderEmail, SenderName, Signature, State,Street,Title, Username, UserRoleId, UserType, LastModifiedDate   FROM USER WHERE LastModifiedDate >= &dateLastRun

The query parameter appears in the mapper and can be set to p_dateLastRun.











Final step in the integration would be to update p_dateLastRun.



 


App Driven Integration

This is appropriate for near real-time requirements. In this case, an event in SFDC will trigger the execution of an integration in OIC. The SFDC adapter supports the following Trigger capabilities - 


Outbound Messaging

Essentially send a message to a service when a record is created/updated in SFDC. Let's implement this for the User business object - 

The adapter in OIC tells us what to do -

So off to SFDC...



I just select a couple of the User object fields. Also note the dummy url I set for the Endpoint URL. This will be replaced later.



 
I now add a workflow rule to ensure the message is only sent on User update - 



 I add rule criteria - e.g. only fire if country = "Ireland" etc.


I click Add Workflow Action -





The Outbound Message definition has been updated accordingly - 


I retrieve the wsdl, this will be required by the integration trigger configuration - 


I save this file locally - 


Back in OIC, I upload the wsdl to the trigger - 
























The adapter configuration is completed and I'm advised of the next steps -


I just add a Log action so I can test immediately -


I activate and pickup the endpoint url - 

I replace the dummy url I set for the Outbound Message in SFDC - 


I activate the rule, then change the alias for user - Julius Martov - 

The OIC integration is triggered - 

Streaming API

Streaming api is probably the way to go when implementing push from SFDC. According to Salesforce - Streaming API enables streaming of events using push technology and provides a subscription mechanism for receiving events in near real time

Check out my post here for a step by step description on how to implement such - 


 





No comments: