Simple use case here - users created in SFDC are pushed to a downstream app. If a user is deleted/deactivated in the app, the SFDC pendant needs to be deactivated.
But this post will cover more features of the adapter, including use of the SFDC Bulk API - however, you have to use the Resource Owner Password Credentials security policy or Authorization Code Credentials in order to use V2 of the SFDC Bulk API.
I take this as an opportunity to check out this security policy -
This is how I get such -
I begin by creating a new Connected App in SFDC -
The callback url has the following format - https://hostname from EndpointURL/icsapis/agent/oauth/callback
Now to the scopes - essentially specifying what the app will be allowed to do in SFDC.
I just give full access, at this stage -
Now back to the connection definition in OIC - I use the key and secret.
So why would I use Resource Owner Password Credentials? Again back to us wanting to use v2 of the SFDC Bulk API.
Here is the difference, compared to Salesforce Username Password Policy -
Actions available are the same -
but let's check out the Bulk Data Operations -
here are the options - Bulk v2.0 will be used later on in this post.
Compare this to Salesforce Username Password Policy -
Updating User in SFDC
So t the simple user update - this can be done easily using the OIC adapter for SFDC -
In the following sample, I retrieve active users from SFDC - one of these, Julius Martov, will be updated -
As you can see, Julius is active -
Here is the simple integration flow -
GetSFDCUsers is configured with the following SOQL -
SELECT ID, CommunityNickname, EMAIL, FirstName, LastName, IsActive from User
Note the testing capabilities of the adapter wizard -
The Switch action filters out the Mencheviks and sets them to deactivated -
I also set the alias, just for the sake of it.
The Active flag is set as follows -
Let's test it out -
Validate in SFDC -
Julius is now known informally as the mart, and yes, the user has been deactivated.
Now let's do the same using the SFDC Bulk api v2.
Updating User in SFDC using Bulk API
Now to the Bulk API implementation - The ROPC based connection I created earlier, will be used.
Bulk api is essentially asynchronous file upload. My first challenge was getting the correct file format for SFDC Users. In the end, I did an export, selecting only the User object -
The exported file is as follows -
This will now be my input file for bulk load. I copy this to the OIC File Server -
Now to the upload integration -
Here I read the file using the ftp adapter, then invoke the bulk load via the SFDC adapter. The latter is configured as follows -
I map a couple of fields - ID, Alias, IsActive etc.
I then add another Bulk API invoke via the adapter - Final Batch - indicating I have no more files to process. SFDC Bulk API has a size limit on files, so you could end up having multiple input files, hence FinalJob.
I run a test - and check in SFDC -
Simple logic here, we invoke the SFDC bulk api - getFailedRecords - this returns the error(s) and data as a .csv file. This file is stored in the OIC VFS (virtual file system), hence the next action being Stage File - List Files. Then each error file is written to the OIC File Server via the ftp adapter.
The SFDC Invoke is configured as follows -
I check out the error.csv file -
Ok, so Alias is limited to 8 characters,
I'll amend it to Jmart in the input file and reload.
I check out the user in SFDC -
I just have to set the active value in the input file to 0, in order to deactivate the user.
No comments:
Post a Comment