Announcement

Collapse
No announcement yet.

Workflow: change in billing data

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

  • Workflow: change in billing data

    I want to have the old and the new billing postal code sent by email if it changed.

    Condition : Formula : entity\isAttributeChanged('billingAddressPostalCod e')

    Could you give an example on how to get the current and
    previous billing postal code in the email to be sent out?

    Thank you
    Last edited by rinorway; 01-21-2020, 11:16 AM.

  • #2
    I recommend using BPM for this.

    You can assign a previous value to a process variable. Then you can use this variable in an email template (since the recent advanced pack version).

    Code:
    $previousCode = entity\attributeFetched('billingAddressPorstalCode');
    $newCode = entity\attribute('billingAddressPorstalCode');
    In the email template:
    Code:
    {$$previousCode}
    
    {$$newCode}

    Comment


    • #3
      Thank you,

      Where do assign the process variables in workflow?
      I know I can do assignment in "update target record" but not in "send email"
      I know you can do a script task in BPM, it would be nice to have script task as possible action in workflow as well.
      BPM is great for complex workflow, but I want to use these vars in workflow, not BPM


      Comment


      • #4
        It's not possible with workflows.

        You can do a trick by copying a previous value to another field. This will work out in workflow. You need to run sequential workflow. First updates, second sends email. It's almost the same complexity as BPM, but w/o having not needed processes stored in the system.
        Last edited by yuri; 01-21-2020, 10:57 AM.

        Comment


        • #5
          But I'd recommend using BPM with self removal.

          Update Process Record > formula:

          deleted = 1;

          Comment


          • #6
            Ok tried BPM, but that will result in trigger AFTER the change, yielding both attributes to be the same.

            Click image for larger version

Name:	2020-01-21_11-50-48.png
Views:	236
Size:	8.8 KB
ID:	55074

            Code:
            {
              "list": [
                {
                  "type": "eventStartConditional",
                  "triggerType": "afterRecordSaved",
                  "isInterrupting": false,
                  "id": "alm5zl8r79",
                  "text": "billingAddressPorstalCode  changed",
                  "conditionsFormula": "entity\\isAttributeChanged('billingAddressPostalCode')"
                },
                {
                  "type": "taskScript",
                  "id": "rkq6hz7o7k",
                  "text": "assign $previousCode and $newCode",
                  "formula": "$previousCode = entity\\attributeFetched('billingAddressPostalCode');\n$newCode = entity\\attribute('billingAddressPostalCode');"
                },
                {
                  "type": "taskSendMessage",
                  "from": "system",
                  "to": "specifiedUsers",
                  "messageType": "Email",
                  "text": "Send email with old and new values",
                  "emailTemplateName": "Old new billing postal code"
                }
              ],
              "createdEntitiesData": {}
            Any suggestion what is wrong here ?

            Comment


            • #7
              Really, I forgot the way a process is initiated. I'd add another custom field and set it with a previous value w/ a regular workflow rule.

              Comment


              • #8
                Ok finally ended up with adding this logic to the entity formula (before save script).
                There is no "Before saving record" trigger, hence you will not be able to do the attributeFetched()

                ifThen(entity\isAttributeChanged('step'),
                pstep=entity\attributeFetched('step');
                $logline=string\concatenate(log,"\n At **",datetime\today(),"** step changed from **",pstep," ** to **",step,"**");
                log=$logline;
                );


                For those wondering : the "before save script" is in the entity manager at the drop down carret.

                Comment

                Working...
                X