Home > Forum > Rules, JS, SQL > Notification on comments

Notification on comments
0

Is it possible to get an email notification when somebody is posting a comment without pressing any "move to next path buttons"?
In the screenshot the yellow area.

WEBCON

Sure, you can use the "On instance saving" trigger to send standard and custom e-mails.

This will also work when the Instance is in read-only mode and you press the "Save comment" button.

P.S. For extra spicy memes, you can add a condition that will -not- send an e-mail if a comment is not added, i.e. the user modified the form and "Saved" it, but did not necessarily add a comment.

I made a technical date and time field called "_LastModDate" with time selection enabled.
On save I set this field to NOW (I put in the ADD DATE -8 to cheat time zone settings on my machine)
In the condition, I say that this _LastModDate must equal the date of the last comment added.
Only then will an e-mail be sent.

It's dumb but it works :)
I tried putting the "ADD DATE NOW Hour -8" directly in the condition, but it didn't want to work, I'll try again during the week...

PS2. This might be a nice topic for a future Quick Tips video :)

MVP
In reply to: Grzegorz Straś

Sure, you can use the "On instance saving" trigger to send standard and custom e-mails.

This will also work when the Instance is in read-only mode and you press the "Save comment" button.

P.S. For extra spicy memes, you can add a condition that will -not- send an e-mail if a comment is not added, i.e. the user modified the form and "Saved" it, but did not necessarily add a comment.

I made a technical date and time field called "_LastModDate" with time selection enabled.
On save I set this field to NOW (I put in the ADD DATE -8 to cheat time zone settings on my machine)
In the condition, I say that this _LastModDate must equal the date of the last comment added.
Only then will an e-mail be sent.

It's dumb but it works :)
I tried putting the "ADD DATE NOW Hour -8" directly in the condition, but it didn't want to work, I'll try again during the week...

PS2. This might be a nice topic for a future Quick Tips video :)

Thank you Grzegorz, you reminded me of an itch I've forgotten over the time.
When I first used the 'Last comment' variable some years ago it was strange for me, that it didn't return the latest/current/new comment. Also the name clearly states, that it will always return the last variable.

Since then I learned a few things so I put together a simple business rule, which will return the current comment otherwise it will return an empty string.
Maybe this will help some people:
https://daniels-notes.de/posts/2024/current-comment
select
case
when WFD_Version = 1 then '{WFLASTCOMMENT_TEXT}'
when cast(WFD_Description as varchar(max)) <> cast(WFH_Description as varchar(max)) then '{WFLASTCOMMENT_TEXT}'
else ''
end as CommentText
, WFD_Description
, WFD_Version
, WFH_Version
, WFH_Description
from WFElements left join WFHistoryElements
on WFD_ID = WFH_OrgID
and WFH_Version = (WFD_Version -1)
where WFD_ID = {WFD_ID}


Best regards,
Daniel

In reply to: Jacek Wojnar

yes - because the "save" action is not performed when moving a document by the path.

In such a situation, you need additionally to take action to entry or exit each step.

this article is confusing:
https://community.webcon.com/posts/post/pending-in-transaction-vs-pending-after-transaction/347/3
because if you read it you think it should save .. so you expect action "on save" will be triggered but you need read help
to see https://docs.webcon.com/docs/2024R1/Studio/Workflow/Workflow_GlobalAction3/
" Upon instance saving – the action is executed when an instance is saved, [b]but does not advance to the next step.[/b]