1

I'm not a developer, so I might be missing something stupid. We are integrating Salesforce with another system via Mulesoft. The Mulesoft developers are trying to use the Composite API for the following use case. They first need to do a GET to find any PersonAccount records based on email address. If found, a PATCH call should run. If not, a POST call should run. I'm having trouble finding info on this. Where would the logic sit? Surely not in the API call? We are trying to avoid having to do 2 calls, i.e a GET and then a POST/PATCH. So is this at all even possible?

I've played around with the Salesforce Flow API. So via Postman I'm passing the values into a record variable in the Flow and the Flow then handles all the logic. However, the response it sends back after the flow executed is only whether it was successful or not. Mule needs the record Id of the record that was created or updated and also wants to know whether the record was created or updated. Is it possible to change the response message that gets sent back or should we rather go with an Apex class?

1
  • The logic is wired into the Composite call, this is out of the box. Using Composite in this fashion leaves very little room for error handling. To answer the unasked question, the implementation you're seeing is very typical. But what is more standard in Mulesoft world is to not use Composite but make 2 separate calls.. There will be business rules (incl. error handling) implemented via Mulesoft scripting/DataWeave or connectors between the two calls.
    – identigral
    Jul 13, 2022 at 16:10

1 Answer 1

1

Unpopular option, I don't feel you should be using flow or composite API but build your own Apex Rest web service.

An external system should not directly CRUD directly in SF database. It creates tight coupling, you won't be able to change your database columns or behaviour without making an external system make a change in theirs. Whenever you create Rest Service you define request response structure, its a binding contract that does not need to correspond to your database structure. It gives you more flexibility.

If you use a flow you don't have proper logging and errors are not developer-friendly. Plus it discourages writing unit test cases.

1
  • Yes but really the answer is "it depends". For orgs that are willing to develop and maintain all that custom code, agreed. For other orgs - Composite, Mulesoft, Flow...and other no-code or less-code options are more appropriate.
    – identigral
    Jul 13, 2022 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .