Announcement

Collapse
No announcement yet.

FlowCharts Send Http Request (beforeValue)

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

  • FlowCharts Send Http Request (beforeValue)

    Hello Yuri,

    is there any possibility to have the beforeValue of attribute (if you see image, start event is "change") ?
    it's important for us

    Best Regards

  • #2
    Hi,

    You can utilize Workflows instead. Have 2 actions.

    The first action (Execute Formula) sets a before-value to a variable.

    $myVar = entity\attribute('attributeName');

    The second action is Sent HTTP Request that utilizes that variable.

    This is possible since the recent version of advanced pack. We added the logic that variables are passed along all actions of a single workflow rule.

    Comment


    • #3
      yuri How do you use that variable in the action "Create notification" -> message template?

      Like {$myvar}

      This would be handy for quick debugging of workflows.

      Comment


      • #4
        yuri
        Would you anyone be so kind to share a task json example here ?

        Whatever I try (simple workflow : onchange of Contact entity) the myVar will not get parsed, when I use
        Code:
        myVar =
        not either...

        Goal is to post a bunch of data outside for audit purposes and MS Teams notifications.


        Code:
        [
        {
        "formula": "$myVar = \"123\";\n",
        "cid": 0,
        "id": "...",
        "type": "executeFormula"
        },
        {
        "requestType": "POST",
        "contentType": "application/json",
        "content": "{\"a\":\"{$$myVar}\",\"b\":\"{$lastName}\"}",
        "requestUrl": "https://webhook.site/3d830....",
        "headers": [],
        "cid": 1,
        "id": "...",
        "type": "sendRequest"
        }
        ]
        Last edited by rinorway; 11-30-2020, 02:41 PM. Reason: clarified

        Comment


        • #5
          Hello,

          not try still .. but maybe this :
          $oldValue = entity\attributeFetched('assignedUserId')


          MS Teams notifications : waouwww .. it's easy to implement ?

          Comment


        • #6
          yuri A working example (even a screenshot) of a workflow with a variable assignment and using its value in a HTTP action would be very welcome, or a link to an example in the manual.

          So far I have not been able to get any var assigned in "executeFormula" to be available in another task using a placeholder

          Thank you
          Last edited by rinorway; 12-01-2020, 10:53 AM.

          Comment


          • #7
            Hello,
            i have try to pass a variable so : $var or $$var.. no luck .. but in BPM work.
            so maybe https://docs.espocrm.com/administrat...ula-in-actions
            create a custom field .. set your variable then in postHttp use it

            And on doc :
            Available placeholders:
            • {$attribute} – a value of an attribute (field) of a target record; e.g. {$description}, {$assignedUserId} (see info about attributes);
            • {$$variable} – a value of a variable (available only in BPM process); e.g. {$$myVariableName}

            Thanks for tips for MS Teams.. it's easy

            Regards
            Last edited by item; 12-01-2020, 03:39 PM.

            Comment


            • #8
              Ok, hmm what a pity... i missed the (available only in BPM process) remark, how easy would it be to have that in workflows as well...

              Comment


              • #9
                Maybe a feature request .. or a bug, Yuri seemt say "it's possible in workflow" .. and no result in workflow

                Comment


                • yuri
                  yuri commented
                  Editing a comment
                  I will fix for workflows in the next release.

              • #10
                Many Thanks Yuri ..

                Comment


                • rinorway
                  rinorway commented
                  Editing a comment
                  Totally agree, very nice to fix that Yuri,

                  For others : you should not post issues for advanced pack in github espo repo (like i did), that is only for espo/espo and does not contain the advanced pack.

              • #11
                Confirmed : Tested with Advanced Pack 2.6.5 Workflows: Fixed a bug that variables not being passed from between actions.

                eg : Track changes in contact lastName:

                Execute Formula Script
                $old=entity\attributeFetched('lastName');
                $new=entity\attribute('lastName');

                Send HTTP Request
                Request Type POST
                Content Type application/json
                URL: https://webhook.site/xxxxxxxxxxx?oldname={$$old}&newname={$$new}
                Payload: {"old name":"{$$old}","new name":"{$$new}"}










                Comment


                • item
                  item commented
                  Editing a comment
                  Thanks rinorway,

                  it's something strange..certainly my fault :
                  execute formula :
                  $old= ...
                  you put one $

                  and on second action, you put two $

                  i have not tested your tips but if it's the solution.. perfect.. that's clarify my mistake

                • rinorway
                  rinorway commented
                  Editing a comment
                  Yes correct, you should use {$$old} : https://docs.espocrm.com/administrat...ula-in-actions

                  Available placeholders:

                  {$attribute} – a value of an attribute (field) of a target record; e.g. {$description}, {$assignedUserId} (see info about attributes);
                  {$$variable} – a value of a variable (available only in BPM process); e.g. {$$myVariableName}

                  BTW, you could have used the attribute directly like $lastName, but since assigned to $new, it should be $$new

              • #12
                Originally posted by rinorway View Post
                Confirmed : Tested with Advanced Pack 2.6.5 Workflows: Fixed a bug that variables not being passed from between actions.

                eg : Track changes in contact lastName:

                Execute Formula Script
                $old=entity\attributeFetched('lastName');
                $new=entity\attribute('lastName');

                Send HTTP Request
                Request Type POST
                Content Type application/json
                URL: https://webhook.site/xxxxxxxxxxx?oldname={$$old}&newname={$$new}
                Payload: {"old name":"{$$old}","new name":"{$$new}"}
                Hi, I tried this, but without success.
                Sent the image of workflow attached. With different ways to get the value of NAME!

                The payload received is below.

                {"post":"teste",
                "parent":"Opportunity",
                "id":"612e5284a16697ca4",
                "Nome":"",
                "Nome2":"{$$name2}",
                "Nome3":"{$$name3}",
                "CodigoOportunidade":"{$codproposta}",
                "related":"",
                "Email":"{$createdBy.emailAddress}",
                "createdAt":"2021-09-06 19:15:08"}



                any advise? Thanks

                Comment


                • #13
                  Originally posted by rodrigocoelho View Post

                  Hi, I tried this, but without success.
                  Sent the image of workflow attached. With different ways to get the value of NAME!

                  The payload received is below.

                  {"post":"teste",
                  "parent":"Opportunity",
                  "id":"612e5284a16697ca4",
                  "Nome":"",
                  "Nome2":"{$$name2}",
                  "Nome3":"{$$name3}",
                  "CodigoOportunidade":"{$codproposta}",
                  "related":"",
                  "Email":"{$createdBy.emailAddress}",
                  "createdAt":"2021-09-06 19:15:08"}



                  any advise? Thanks
                  yuri ?

                  Comment


                  • #14
                    Late answer, but here we go :

                    The trick is to use :
                    Code:
                    workflow\targetEntity\attributeFetched()
                    instead of
                    Code:
                    entity\attributeFetched()
                    Click image for larger version

Name:	image.png
Views:	369
Size:	15.5 KB
ID:	88302
                    Attached Files

                    Comment

                    Working...
                    X