function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
benwalkbenwalk 

Integration User acting on behalf of other Users

I have an in-house application that support agents interact with to work on cases, modify accounts, contracts, etc.  This application uses the SOAP API and an integration user to push updates to Salesforce.  The problem I'm having is that the updates are made by the integration user instead of the support agent users (who have accounts in Salesforce) because the calls are all made through the API.  It would help with reporting and other business logic calculations if the create or update was done by the originating user, not the integration user.

Is there a way to create and update SFDC objects as another user via API?
Bohdan DovhanBohdan Dovhan

I think yes but in this case those users may need access to corresponding objects and their credentials should be used in SOAP API Calls like following:

 

String username = 'username';
String password = 'passwordWithSecurityToken';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);

soapSforceCom200608Apex.Apex apexWebSvc = new soapSforceCom200608Apex.Apex();
soapSforceCom200608Apex.SessionHeader_element sessionHeader = new soapSforceCom200608Apex.SessionHeader_element();
sessionHeader.sessionId = loginResult.sessionId;
 

 

benwalkbenwalk
Thanks for the tip!  I'm looking for a way to do it without the other user's credentials, though.  As an integration user I don't have those users' credentials (e.g., a System Administrator can login as another user to perform an action, but doesn't have those users credentials).
buyan thyagarajanbuyan thyagarajan
@benwalk,
 This can be done by apex with mapping between sfdc user agents and your in house application agent. So here is how you can do this.
1. On the sfdc side, for each agent user, you can create a custom field called inhouse agent userid and store the userid on the user object.
2. Now you can create a trigger on the account where would check the in house agent user id and if it exists, it would query the user object and get the actual sfdc user agent and update the owner of the account or user modified to sfdc user for the account.
Let me know if this helps and why do you want to do this integration? Please click like if you like my answer..
Thanks
Buyan
benwalkbenwalk
This is a good idea for a workaround, but it doesn't quite answer the question.  It would solve the problem, but it requires additional maintenance to keep the mapping up to date / additional Apex classes.