Being part of the Advanced Workflow package, the “Try/Catch” shape is a very useful component when it comes to error handling. The “Try/Catch” shape is implemented BEFORE the actual shape that we wanted to capture and will only execute in the situation as outlined here.
One advantage of using the “Try/Catch” is the capability to capture the original data. This will be useful, in situation when we need to examine the error data.
We have a scenario where we were trying to update the Salesforce Contact from a csv flat file. Below is the sample data:
As you can see from the sample data above, record two will fail because the ‘externalId’ field is missing and Salesforce will not be able to find a matching record for update.
Now, let’s look at a sample process without implementing the “Try/Catch” shape:
From the example above, record two will fail and throw error message from the “Exception” shape as we expected. But what if we need to examine the source error data? We may not be able to get the source data easily from the sample process above once the process has passed the update operation as it then return the update response instead.
Lets look at how does the “Try/Catch” shape help in this case.
With the “Try/Catch” shape being introduced, the failed record will be catched and we can then manage the error record, i.e. re-write them into an error folder, send notification related to source error record, etc.