Solution provided by ChatGPT …
I explained what I wanted to ChatGPT and, after a bit of back-and-forth, it came back with a script that works. See below:
function onEdit(e) {
if (!e) return;
var sheet = e.source.getActiveSheet();
var row = e.range.getRow();
var column = e.range.getColumn();
if (sheet.getName() === “Transactions” && e.range.getColumn() === 4) {
var category = sheet.getRange(row, 4).getValue();
var tags;
if (category.indexOf(“731”) >= 0) { //CHANGE
// if (category.includes("731"))
tags = "731 Main, Rentals"; //CHANGE
} else if (category.indexOf("744") >= 0) { //CHANGE
tags = "744 Broad, Rentals"; //CHANGE
}
if (tags) {
sheet.getRange(row, 7).setValue(tags);
}
}
}
Summary: This script replaces the contents of the Tags column “G” in a sheet named “Transactions” if the value in the Category column “D” is changed and if the changed value contains either 731 or 744. If the new category contains 731, the script adds two values separated by a comma to the tags column. If the new value contains 744, it adds different values to the Tags column.
I tried this on a test version of Tiller that I downloaded from Tiller. The name of the test version is Sharing Tiller Foundation Template. I don’t remember where I found it but I’m sure Tiller’s excellent Customer Support team can tell you if you want to try this.
This code includes the values that I’m using to match in the Category column and the values I want to add in the Tags column. You can replace my values with yours if you want to test this. I marked the lines that need to change with // CHANGE
Finally, note that this script assumes that the Category column is D and the Tags column is G. Those values will need to change if your sheet has different column assignments.
FYI … This eliminates a manual process that was needed if AutoCat didn’t categorize the transaction. I have AutoCat rules that assign the Category, standardizes the Description, and adds tags to some transactions if the match rules are met. But, if I have to set the category manually for any reason, I had to remember to assign the tags and do it consistently. This little script will do it automatically and consistently.