Forum Discussion

MikeKlausing's avatar
MikeKlausing
Qrew Assistant Captain
6 years ago

Automation Loop

I have an automation that is triggered when a field "order status" is changed to Approved. Order status is changed to Approved when the user clicks a button. 

My issue is that when one record is approved I can get all of the data I want moved over to the other table like I need, however when the automation is triggered for 1 newly approved record, it duplicates already approved records as well in my table the automation is copying to. 

How can I get it to only move over newly approved records and not every record that has "approved" in the order status field. Just the one that was clicked on, because the other approved orders would have already been moved over there.



------------------------------
Mike Klausing
------------------------------
  • Mike,

    You're already on the right track by thinking about this Automation in terms of the "state" of a record. We just need to determine which state change should trigger the Automation. The record's order status is a state, and it does help identity the type of records this Automation should pick up. However, what we really want to know about the record's state is "should it sync," and using a record's order status state isn't giving us a complete answer for the state of "should it sync." I've found tracking the state of "should it sync" is easier by using a "trigger checkbox."

    Here's a quick example:
    Let's say the trigger field is named  [Copy Trigger]. When a user clicks the "Approve" button, that record would be updated to have [Order Status] = "Approved" and [Copy Trigger] = True. The automation would then search for records where [Copy Trigger] = True, and set [Copy Trigger] = False on the first step. Since we're just looking for the state of "should it sync" instead of the state of "Order Status = Approved", we are excluding any "Approved" records that have already sunk. To recap:
    1. Button sets [Order Status] = "Approved" and [Copy Trigger] = True
    2. Automation triggers on record update where [Copy Trigger] = True
    3. Step 1 of Automation is to set [Copy Record] = false on the record that that triggered the Automation
    4. Automation then does stuff

    ------------------------------
    Evan Westbrook
    PRIME Developer
    Harder Mechanical Contractors Inc.
    Portland OR
    ------------------------------
    • MikeKlausing's avatar
      MikeKlausing
      Qrew Assistant Captain

      Perfect, thank you!


      Basically we are having the [Copy Record] field be something that we can turn on with the button and the automation turns it off or makes it false before completing, therefore making sure it doesn't get copyed a 2nd time when the next order is approved right?

       

      Thank you,
      Mike Klausing

       



      ------Original Message------

      Mike,

      You're already on the right track by thinking about this Automation in terms of the "state" of a record. We just need to determine which state change should trigger the Automation. The record's order status is a state, and it does help identity the type of records this Automation should pick up. However, what we really want to know about the record's state is "should it sync," and using a record's order status state isn't giving us a complete answer for the state of "should it sync." I've found tracking the state of "should it sync" is easier by using a "trigger checkbox."

      Here's a quick example:
      Let's say the trigger field is named  [Copy Trigger]. When a user clicks the "Approve" button, that record would be updated to have [Order Status] = "Approved" and [Copy Trigger] = True. The automation would then search for records where [Copy Trigger] = True, and set [Copy Trigger] = False on the first step. Since we're just looking for the state of "should it sync" instead of the state of "Order Status = Approved", we are excluding any "Approved" records that have already sunk. To recap:
      1. Button sets [Order Status] = "Approved" and [Copy Trigger] = True
      2. Automation triggers on record update where [Copy Trigger] = True
      3. Step 1 of Automation is to set [Copy Record] = false on the record that that triggered the Automation
      4. Automation then does stuff

      ------------------------------
      Evan Westbrook
      PRIME Developer
      Harder Mechanical Contractors Inc.
      Portland OR
      ------------------------------
      • DonLarson's avatar
        DonLarson
        Qrew Elite
        Mike,

        I suggest going one step further.   The check box method will eliminate the copying of the old records.  However there can be value in knowing the sync status and timing.  

        A new relationship to Sync Status will do this as well and show you the progression and timing. 

        Orders<<  Order Sync Change  >> Sync Status
        Imagine that the Sync Status Table has three values

        • New
        • Pending
        • Synced

        When the Order is created, the Sync Status is New
        When the Order status is Approved, the Sync Status moves to Pending
        When the Sync Automation completes, it changes Sync Status to Synced.

        You can now report against both of the different Status types in the Orders Table.  Invariably questions come  later about the timing of the status changes and simple check box does not give that to you.  Your intermediate table for the change can do a lot of useful things.

        ------------------------------
        Don Larson
        Paasporter
        Westlake OH
        ------------------------------