[DONE] Checklist Add Comment after Completed

I’m trying to create an automation that adds a comment whenever a checklist item is completed. I thought the automation would be something like this:

However, that automation gives me this result:

I was expecting the comment to output, Testing 1 completed on 2024-08-30 11:58:12

What am I doing wrong?

2 Likes

Hi Luis,
I think your automation would work if you would have only one check to complete.
But in this case I think you need to first create array of checklists, script filter where you also need previous value to be incomplete, similar to what Jason did here.

Hope this helps.

2 Likes

Hi Luis

I know I sent you some pointers on this yesterday but I have a bit more time this morning so a more full explanation follows :slight_smile:

I think what you are trying to do is:
Melotte Consulting - 76Grieil-002120

which I have done by getting the previous values and the current and then comparing the two to find the new:

console.info(jsonata('$[completed=true].title').evaluate(app_one_field_checklist_complete_iterable));
console.info(jsonata('$[completed=true].title').evaluate(app_one_field_checklist_complete_iterable_previous_value));

// ##### ---- Variables ---- #####
const current = jsonata('$[completed=true].title').evaluate(app_one_field_checklist_complete_iterable);
const previous = jsonata('$[completed=true].title').evaluate(app_one_field_checklist_complete_iterable_previous_value);


// ##### ---- Find the items in that are new ---- #####
const difference = !!previous ? current.filter(item => !previous.includes(item)): current;

console.log(difference);
var_checklist = difference;

This question came at a perfect time for me as someone I am coaching came up with what I think was a really good way of using checklist items but they hadn’t quite got it working and I had said I would take a look at it. This should give them the answer to their ‘homework’ :wink:

7 Likes

Thanks, Jason. That worked perfectly.

4 Likes