AutoCat when Category is Manually Assigned?

I have AutoCat rules that enter specific tags when the rule is matched.

But, if I have to enter the category manually, I don’t think AutoCat is triggered to enter the tags. I have to remember to do it and to do it consistently.

Using AutoCat or an entirely different method, is there a way to automatically enter specific text in the Tags column when the value of the Category field is manually entered and in such a way that it doesn’t interfere with AutoCat?

If the value in the Category column is blank, enter “xyz” in the Tags column if the Category contains “value1 or value 2”.

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.

1 Like

AutoCat should e able to do what you are proposing at the end of your first message, @ScottC. It is just a rules processing engine: if rule “filters” are all true, apply all (non-blank) “overrides”.

You will need to toggle AutoCat to run on all transactions (not just uncategorized).

WORD OF WARNING… personally I’m not a huge fan of running AutoCat on “All Transactions” as it can overwrite manual changes I made.

You’re absolutely right, Randy. I wonder how many other people know this is possible.

I had assumed that AutoCat was “looking for” values in the Description column and applying its changes based solely on that criteria. In my case, the description from the bank isn’t enough to categorize a transaction to one of our rental properties. e.g. A Home Depot transaction could be personal or related to a rental property.

But, I just added two new rules to a test file. I set the Category column to 731 Insurance and "731 Main, Rentals into the Tags column. Changing the category of an existing transaction did trigger the AutoCat rule. The two tags were added.

Now I need to read the AutoCat documentation again to see if (how) to trigger the rule if the Category “contains” a value instead of “is” the value because I have about 20 categories that start with 731 and another that starts with a different street number.

As I recall, this is possible.

Thanks for this tip.

ScottC

Well … that was easy. The AutoCat tab already had a column “Category Contains.” I created two new rules.

In the Category Contains column of the AutoCat tab, I entered 731 in one row and the other street number in the 2nd. I added the tags that I wanted in the Tags column separated by a comma. I didn’t enter anything in the Category or Description columns.

It worked perfectly. When I changed the category of an existing transaction (in the Transactions tab) to any Category beginning with 731 or the other, it entered the tags I wanted into the Tag column.

(edited for clarity 2023-02-09)

It’s a pretty flexible and powerful tool. I’m glad to see that you are harnessing it, @ScottC! :racehorse:

OK, wait a sec – so if I have transactions where I want to match the description and then change it, but I do NOT want to change the category, I can just leave Category blank and it will work?