Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Trying to create automation to input tags on certain new products that meet the criteria

Topic Labels: Automations
440 1
cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to figure out how I could create an automation that would fill one cell with tags when the new record that I have made consists a certain word. For example I add a product type chair, it would add all the tags that I would use for chair.

Is this possible to do in automation or should I try to think of a script?

Thanks for the help!

1 Reply 1

You could have several different Automations, one for each keyword, that inserts a predefined list of tags into the multiselect field.

Or you could use a single Automation that includes a Run a script action. Here is a very rudimentary script that checks incoming text (provided by an input config variable) for matching predefined keywords:

let {text} = input.config()

let keywords = [
    // Add more {keyword: "", choices: []} objects as necessary
    {keyword: "new", choices: ["New", "Featured"]},
    {keyword: "chair", choices: ["Furniture", "Seating"]},
]

let applicableChoices = Array.from(new Set(keywords.flatMap(pair => {
    let {keyword, choices} = pair
    // remove the ".toLowerCase()" parts if you want keyword matching to be case-sensitive
    if (text.toLocaleLowerCase().includes(keyword.toLocaleLowerCase())) {
        return [...choices]
    }
    return null
})))

output.set("choices", applicableChoices)

Then add a Update record step that fills in the multiselect field with the choices output from the script.