FlowCharts Send Http Request (beforeValue)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    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
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • yuri
    Member
    • Mar 2014
    • 8440

    #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.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • rinorway
      Senior Member
      • Feb 2016
      • 179

      #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

      • rinorway
        Senior Member
        • Feb 2016
        • 179

        #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

        • item
          Active Community Member
          • Mar 2017
          • 1476

          #5
          Hello,

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


          MS Teams notifications : waouwww .. it's easy to implement ?
          If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

          Comment

        • rinorway
          Senior Member
          • Feb 2016
          • 179

          #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

          • item
            Active Community Member
            • Mar 2017
            • 1476

            #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.
            If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

            Comment

            • rinorway
              Senior Member
              • Feb 2016
              • 179

              #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

              • item
                Active Community Member
                • Mar 2017
                • 1476

                #9
                Maybe a feature request .. or a bug, Yuri seemt say "it's possible in workflow" .. and no result in workflow
                If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

                Comment


                • yuri
                  yuri commented
                  Editing a comment
                  I will fix for workflows in the next release.
              • item
                Active Community Member
                • Mar 2017
                • 1476

                #10
                Many Thanks Yuri ..
                If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

                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.
              • rinorway
                Senior Member
                • Feb 2016
                • 179

                #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
              • rodrigocoelho
                Active Community Member
                • Jun 2016
                • 296

                #12
                Originally posted by rinorway
                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

                • rodrigocoelho
                  Active Community Member
                  • Jun 2016
                  • 296

                  #13
                  Originally posted by rodrigocoelho

                  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

                  • rinorway
                    Senior Member
                    • Feb 2016
                    • 179

                    #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:	380
Size:	15.5 KB
ID:	88302
                    Attached Files

                    Comment

                    Working...