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
Puneeth KumarPuneeth Kumar 

Will External API calls invoke Workflows/Approval process in salesforce?

External system(SharePoint) is making SOAP API call to create a record in salesforce, on which creation of records upon meeting a field criteria a workflow should be triggered in updating field values. When a record is created through Salesforce UI the workflow runs fine but when it is getting created through API call seems like workflow is not running. 

So is it something like we cannot invoke Workflow/Aprroval process in sfdc through external API call? If so what thinigs should be done to trigger Workflow/approval process through external SOAP API calls?
ForceMantis (Amit Jain)ForceMantis (Amit Jain)
Workflow rules always execute for single and mass edit UI actions, and for normal API calls. The Import Wizard can disable workflow rule actions, and administrative mass edits (e.g. Replace Picklist Value) will not trigger workflow rules. Also, some other actions, such as transferring record ownership, also will not trigger workflow rules. See the page Workflow Rule Considerations (https://help.salesforce.com/HTViewHelpDoc?id=workflow_rules_considerations.htm&language=en_US) for more information.
Puneeth KumarPuneeth Kumar
Thanks Amit, but how I am supposed to invoke the workflow through API. Is there any other process ? 

In my instance, Sharepoint(UI) is saving a record with field name "Payment option= Company addresss" then the record's address should be updated with company's address. They tried saving the record with API by same Payment option field value but the address fields are not getting filled in record (Workflow already in salesforce with actions of updating address field), where as if I do it in Salesforce UI the workflow works perfectly fine. 

What can be the best solution for this? please advice.
ForceMantis (Amit Jain)ForceMantis (Amit Jain)
You don't need to do anything different to fire workflow from API, Based on case that you have described it look like there is something different in data that is being inserted by UI v/s soap api. There is a possibility of Picklist defaulting which works from UI but not in API i.e. you make a value of picklist as default. This value will come as pre-populated on UI but will be null unless explicity set in API.

You have to check your workflow enter crietia and filter criteria to see what are data differences that are causing workflow to not fire. 

 
Puneeth KumarPuneeth Kumar
Yes by the way Payment option is a picklist value, API is passing one of the picklist value called 'Company address' then on that criteria fields are getting auto populated with related companies address. For reference taken screenshot of that workflowUser-added image
Hargobind_SinghHargobind_Singh
I second with Amit, there is no separate way to initiate workflows. Salesforce behaves the same way for records inserted from UI or workflow. You should look at the records again and check there could be some difference in related company or the record entry itself.
Anupam Bansal (Capgemini)Anupam Bansal (Capgemini)
Hi Puneeth,

Yes, the API calls to salesforce will invoke the Workflow rules / triggers automatically. But this also depends on the User you are performing the action with. Say if your user who you are logged in does not have a permission (Field level security) to the "Payment Option" field, in that case since Workflow rule's criteria can not be checked, so the Workflow rule will not fire. Workflow rules execute in the context of the logged in user while Triggers execute in System context.

Best way to debug this would be check Salesforce debug logs and check which Workflows were invoked due to the action.

Thanks
Anupam Bansal
OSI Consulting
ForceMantis (Amit Jain)ForceMantis (Amit Jain)
Puneet

Payment option is a picklist value, API is passing one of the picklist value called 'Company address', but in workflow configuration screenshot that you posted "Payment Option" is being compared with value "Pay To company". I think this explains why your workflow rule is not working from API call.