BPM Trick - Call Context - only trigger sometimes... How to figure out what to do

Sometimes people want a BPM to only run when certain conditions are happening. I saw this a question on another post, and I thought I would pull out this question and answer into a more generic post.
Did you know that there are “Call Context” fields available to check? What can you find out from the current call context?

  1. The current process that the user is running
  2. The menu option that they ran it from
  3. the user who is trying to run this
  4. the type of client
  5. the Company or Plant that the user is currently running from.
  6. EVEN the CUSTOMIZATION ID that is being run.
    (and a few more).
    Why would I need this? Well, I have seen situations where the BPM only needed to be run if we were actually adding an order from the order entry process, but when the order was coming in from the Web (ecc) we didn’t want to run the process… (or actually, it might have been the other way around).

But sometimes people ask "well, how do I know what to put in my Condition in the BPM?. The easiest and best answer is to use the BPM to tell you first, then create the condition.

  1. start by making a very simple BPM against the business object you are going to run. In my case, i was making the BPM on ABCCode.Update in the PRE processing method.

  2. I created a Message Display box, and displayed all the context fields I was interested in possibly looking at.

  3. I enabled the BPM, and then went to ABC Code Entry and modified the record. When I saved it, the following popped up:
    image

  4. NOW, i can go back to the BPM, remove the display, and add a simple condition to the BPM that checks for the condition I want. In this case, I want to only run this if the ProcessID is IMMT1005… but I could check for only running my BPM if i am in a certain customization, or on a certain client type:
    image

9 Likes

Using call context can allow for fairly powerful BPMs. I have a UD table I use for multiple similar records. It keeps some HR stuff in it, but depending on whether it’s tracking attendance or something like insurance coverage, the records are slightly different. I use the same form with different customizations to create these records. By checking the customization that calls the GetANew method, I’m able to populate certain fields on creation. Call context has a myriad of uses.

1 Like

I just had to recall this trick today and use it for a recipe that was being triggered too many times because it was somewhat recursive (when a discount amount was > x, run BPM…) I had another approval cycle that was marking the item as approved, and in doing so, it was retriggering the BPM and turning off the approval again. But since the approval was coming from outside (not from the sales order entry app) I could filter out that change from being processed.

Recipe. I like that. :grinning:

1 Like

Ahhh… Good old ABCCode.Update

The guinea pig of BPMs

1 Like