2

We have a custom object, Option, which has apex triggers and process builder field updates. We're now introducing an Invocable apex to be called from the existing process. Two reasons why we need to do this:

  1. The new calculation is too complex for a process builder to compute
  2. The new calculation is dependent on the existing calculations performed by the process builder

Within the Invocable method, there's a query on the Option object to refetch the records from the database before proceeding with the calculation. Again, two reasons:

  1. Unlike a trigger, the process builder will NOT have all the fields for the record/records in context
  2. I need a new 'instance' of the records anyway since they ones that process builder provides are 'read-only' (I verified by trying to update the instance directly)

Now the question is, if I refetch the records via a SOQL, will they have the fields updated by the process builder actions preceding the Invocable call?

Note: When I cloned the reference passed by process builder, I was able to update the records but I'm trying to find out if pulling from the DB will have the updated fields

3
  • Is your invocable operation is Synchronous or async? Jul 20, 2016 at 21:59
  • It is sync. Can it be async? I believe an Invocable cannot have any other annotation
    – LVS
    Jul 20, 2016 at 22:01
  • It can be async and call future method also, which not relevant here Jul 20, 2016 at 22:11

1 Answer 1

1

The code execution will be as follows:

  1. Process builder update action (field update)
  2. After update trigger will fire
  3. InvocableMethod

Yes, if you refetch the records via SOQL query it will give you updated records which have been modified in PB update action.

4
  • The invocable method is called as an immediate action in the same Action box as the field update. Will a trigger run happen in between? That means, if I have multiple field updates, each of them makes the trigger run individually?
    – LVS
    Jul 20, 2016 at 23:35
  • For each update After trigger will be fired. Jul 21, 2016 at 0:25
  • 1
    Keep in mind that changes are coming to the Process Builder, so an interested party might want to keep in touch with their success manager/account executive/etc.
    – sfdcfox
    Jul 21, 2016 at 4:15
  • @LVS can you close this question if you got your ans Jul 21, 2016 at 18:04

You must log in to answer this question.

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