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.

Script to inactivate the attachment icon on change requests.

DeIvory Gordon
Tera Guru

Hello,

 

I have a client script below that inactivates the attachment icon on change requests when it is in a state other than "New".  However, I missed a step, I want users who are members of the "GPI- Change Management Office" group to be able to attach icons to change requests regardless of the state the request is in, but I am not sure how to do this.  Thank you for your help.

 

function onLoad() {
    var current_state = g_form.getValue('state');
    if (current_state != 'New') {
        g_form.disableAttachments();
    }
}
1 REPLY 1

KrishnaMohan
Giga Sage

Hi @DeIvory Gordon 

 

check the backend value of 'New' in state field i.e  for New its -1 in OOB.

 

function onLoad() {
    var current_state = g_form.getValue('state');
    if (current_state != '1') { // in my instance backend value for 'New' is 1
        g_form.disableAttachments();
    }
}

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

 

Thanks

Krishnamohan