Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Healthcheck Button Visibility Logic Based on System Comments in General Case

Hanook
Tera Contributor

Objective:*


we are working on implementing  functionality that controls the visibility of a Healthcheck button in the General Case form in ServiceNow. The button's visibility is controlled based on comments added by "system."

 

*Detailed Breakdown:*

When should the Healthcheck button be hidden? The Healthcheck button should be hidden when a comment is added by system in the Additional Comments field of the General Case.
The button should remain hidden for 30 minutes after system adds a comment.

 

*_When should the Healthcheck button reappear?_*

 

After the 30-minute window has passed, the button should reappear and be visible again. If another system comment is added within that 30-minute window, the button should remain hidden for another 30 minutes from the time of the latest comment.

 

1 REPLY 1

M Iftikhar
Tera Sage

Hi @Hanook ,

You can achieve this by controlling the Healthcheck button visibility with a combination of a Business Rule (to track the latest system comment time) and a Client Script/UI Policy (to show or hide the button).

Here’s how you could approach it:

  1. Business Rule (on Case Comments table):

    • Trigger when a comment is added by system in the Additional Comments field.

    • Update a field on the Case record (e.g., u_last_system_comment_time) with the timestamp of the system comment.

  2. Client Script/UI Policy (on General Case form):

    • On form load, compare the current time with u_last_system_comment_time.

    • If less than 30 minutes have passed, hide the Healthcheck button.

    • If more than 30 minutes have passed, show the button.

    • If another system comment is added within 30 minutes, the Business Rule updates the timestamp, and the 30-minute window resets.

This way, the button automatically disappears for half an hour after a system comment and comes back when that time is up.

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.