Hide 'Compose email' button when record is inactive

matej_h
Tera Contributor

Hello community,

 

I'm kinda wondering why something like this is not enabled in Service Now by default. 

The thing is, I've got a request from my customer that they want to disable the email client ('Compose email' UI action) hidden when a record is inactive.

I've already tried some approaches I found online and with the help of my colleagues but nothing really helped (adding a condition "current.active == 'true'" to the UI Action isn't working for me).

I checked this also in plain PDI and found out that by we cannot see the 'Compose email' UI action in incidents when the incident is inactive.

 

BUT

 

In all other tables where the email client is enabled, you can use it even when the record is inactive (RITM, SCTASK, CHG).

 

Have I missed something? Have you guys ever worked on something like this please? Could you maybe explain how this work and if it's even possible to conditionally disable the 'Compose email' UI action?

 

Thank you in advance!

mh

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @matej_h 

 

https://www.servicenow.com/community/developer-forum/email-client-open-hide-is-not-working/td-p/2515...

 

https://www.servicenow.com/community/developer-forum/hide-email-client-icon-for-non-itil-users/m-p/1...

 

https://www.servicenow.com/community/itsm-forum/hiding-email-client-icon-button-for-closed-incidents...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

Mark Manders
Mega Patron

You can create an onLoad client script like this (on the tables where you want to hide it):

function onLoad() {
var active = g_form.getValue('active');
if(active == false) { 
$('email_client_open').hide();
}
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

6 REPLIES 6

matej_h
Tera Contributor

When I adjust the script so it's retrieving 'State' value instead of 'Active,' it seems to be working. So the script would be

 

function onLoad() {
var ritmState = g_form.getValue('state');
if(ritmState == '3') { //3 is the value for Closed Complete (will add also value for Skipped and Incomplete) 
$('email_client_open').hide();
}
}

 

So thank you very much for this, I didn't know about this $ function.

Perfect and new learning.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************