Autocompleting a task upon a note uploaded in a related account?

Logan: 2 weeks ago

so I have accounts that receive notes from an external source. This kind of account will always have a case attached to it, that has the same set of tasks each time. How would I be able to make a case task marked as closed when a note by a certain name is uploaded?

So say the case task is "upload file xyz" and a note is received in the account to which the case is attached. This note says "file xyz finished uploading", so I want to automatically close the task when this happens.

Natalia: 2 weeks ago

It sounds a though the most robust way would be to write a trigger on the Note Object. You could try doing it with Process Builder, but I'm not confident that it would work as I've not tried it. I do know however that the Note Object supports triggers. The ParentID field would be the object that it's attached to which would be the AccountId.

You'd need to filter your notes to for those which were related to Accounts and had either had a body that contained the string "finished uploading" or Title that contained something similar that you're able to control. Once you've collect all of the Account Ids and put them in map with the Note Ids, you'd then query to see which Accounts had open related Cases, and open Tasks related to Cases (could all be done in one query).

Once the query results are returned, it's fairly straightforward to match file name strings in the Note Title with each Task Subject associated with an Account's Case to be able to determine which Task the note allows you to close. Add each one to a list as you iterate through them and perform an update on Task once you're done.