Announcement

Collapse
No announcement yet.

Help with entity\isAttributeChanged() in BPM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with entity\isAttributeChanged() in BPM

    Hi, I have a simple BPM on the Opportunity table that looks like this:
    Click image for larger version

Name:	BPM.png
Views:	468
Size:	17.9 KB
ID:	57952
    The area that I am having issue with is the Inclusive Gateway. What I want to happen is that the "Generic Updates" are always performed and that the "Lost Updates" only get performed if the Stage is "Closed Lost" and that the Stage field has just been changed.

    This is how I have the Gateway set up.
    Click image for larger version

Name:	Inc 2.png
Views:	305
Size:	17.0 KB
ID:	57953
    The thing is that it never takes the "Lost Updates" branch.

    To work out which item on the AND was causing the issue I changed it to:
    Click image for larger version

Name:	Inc 1.png
Views:	275
Size:	14.5 KB
ID:	57954

    And it would take the first branch appropriately. So there seems to be an issue with my usage of the "entity\isAttributeChanged()" function.

    Can you offer any advice?

    Thanks.

  • #2
    Hi Mat,

    It is not supposed to work there. It was intended to work within a single BPM node, single workflow rule or in before-save script. When you check entity\isAttributeChanged, the information about the entity state before the process is started is not available.

    Comment


    • #3
      Ah ok, so I will create a separate stream them that uses a Conditional Start Event

      Comment


      • #4
        Hi yuri I am working on this again. I now have a simple BPM that triggers when an Opportunity is written, and the stage changes, thus:

        Click image for larger version

Name:	Start.png
Views:	294
Size:	10.0 KB
ID:	59148

        This works well.

        I now want to make some decisions based on the old value of "Stage" which I am struggling to get. The code that I am using in an "Update Target Record" is:
        Code:
        $old_stage = entity\attributeFetched('stage');
        $new_stage = stage;
        
        description = string\concatenate("old: ",$old_stage,", new: ",$new_stage);
        When this runs, both variables have the same value, and that is of the new value. How do I get the original value?

        Thanks.

        Comment


        • #5
          Hi,

          It's not possible as a mentioned above. You can create a read-only field and copy fetched value to there with 'before-update script' (Entity Manager > formula).

          Before-update script:
          previousStage = entity\attributeFetched('stage');

          Then read it in BPM.

          BTW there's already a field lastStage in opportunity. The last stage before stage becomes Lost or Won is written to there.
          Last edited by yuri; 06-05-2020, 06:34 PM.

          Comment

          Working...
          X