Jan 11, 2022 07:14 AM
In our base, users can trigger an automation via a checkbox. When the box is checked, the automation creates a linked record in a different table and populates the fields with various text, form links, etc.
The problem is if a user does the following we get duplicate linked records:
How can we either prevent a duplicate linked record from being generated, can the automation check if a linked record exists before proceeding? Or is there a better trigger we can use that is one-directional, meaning it can only create the linked records once? I was able to do this with a button + scripting app, however they are not usable in Interfaces which is where we’re applying this functionality.
Solved! Go to Solution.
Jan 11, 2022 09:26 AM
I recommend using a single select field instead of a checkbox, with two values: “Create Linked Record”, and “Done creating linked record”. Initially this field will be blank. Then the user will change the value to “Create Linked Record.” This triggers the automation script. The automation script checks if there is a linked record, and only create the linked record if there isn’t one. The script also changes the single select to “Done creating linked record.” This way users are less likely to reset the single select, the way they would uncheck a checkbox. If the user does change the single select again, the script will simply change the single select back.
Jan 11, 2022 07:39 AM
Have the checkbox automation run a script instead of using the “Create Record” action. Note that you will need a Pro subscription to run a scripting action. The logic in your existing script to check for an existing linked record should be fairly easy to convert to an automation script, although it will need some changes.
Another option is to wait until you get access to conditional logic for automations (currently in beta).
Jan 11, 2022 07:58 AM
This makes sense, and would prevent duplicate records. One issue is it would be possible to have an unchecked box even if the linked record was already created, which could be confusing for users.
I didn’t know conditional logic was coming for automations, that’s exciting. Any word on if they will increase the number of automations?
Jan 11, 2022 09:26 AM
I recommend using a single select field instead of a checkbox, with two values: “Create Linked Record”, and “Done creating linked record”. Initially this field will be blank. Then the user will change the value to “Create Linked Record.” This triggers the automation script. The automation script checks if there is a linked record, and only create the linked record if there isn’t one. The script also changes the single select to “Done creating linked record.” This way users are less likely to reset the single select, the way they would uncheck a checkbox. If the user does change the single select again, the script will simply change the single select back.