Announcement

Collapse
No announcement yet.

Workflow->Email : your field "X" changed from 001 to 002

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

  • Workflow->Email : your field "X" changed from 001 to 002

    I want to notify people that a field value changed, similar to what is done in the stream when a field is audited.

    Workflow :

    Trigger Type = After record saved (created or updated)
    Conditions = Any -> field X changed
    Actions = send email

    Content of template should state :

    "Hi there, field X changed from 001 to 002"

    What is the preferred way to do that?

    Thank you,

    ( duplicate of https://forum.espocrm.com/forum/exte...n-billing-data )

    ----------------------


    It would be already OK if in the Workflow part an assignment could be done, eg :

    $previousCode = entity\attributeFetched('fieldX');
    $message = string\concatenate("You changed fieldX, previous value was:", $previousCode);

    and that the declared $message would be available in template (message or mail)
    Last edited by rinorway; 06-22-2020, 04:18 PM.

  • #2
    I think you can create notifications as a workflow action.

    Comment


    • #3
      Correct, but the question is how to get eg.
      entity\attributeFetched('fieldX') in a template variable in order to
      display the old value (before change) and the current
      value (after change) in the message/email

      Comment


      • #4
        It's a bit ugly, but you could create a new field for the changed fields and use it in the email. In the same workflow you can append multiple strings to it if multiple fields changed. something like this previousValueText = string\concatenate(previousValueText, "\n", $message); or just make a field for each value you care about. like previousValue1,previousValue2,.. you assign them when changed and set it to nothing when unchanged. this would mean to use if statements in formula or multiple workflows

        Comment


        • #5
          True, but there must be an internal procedure already, since the stream hook for audited fields does exactly that. (pushing old and new value to notes), so it would make sense to expose that functionality in a formula.

          Comment


          • #6
            A workable approach using functionality from advanced pack 2.6 is presented by yuri at https://forum.espocrm.com/forum/exte...st-beforevalue

            It uses workflows functionality :
            • Formula variables passing from action to action. The ability to use variables defined in a previous action of the same workflow rule.
            • New ‘Execute Formula Script’ action.


            Last edited by rinorway; 11-24-2020, 10:15 AM.

            Comment

            Working...
            X