How to Hide Attachment icon when the ticket status become "closed"

s_s
Giga Contributor

Hello.

When I closed a ticket, I would like to hide the attachment icon.

find_real_file.png

I referred to https://community.servicenow.com/community id=community_question&sys_id=14fa8dc0db8b5b0423f4a345ca96... and created client script as below.

find_real_file.png

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    var checkValue = g_form.getDisplayBox('state').value;
    if (checkValue == "Closed"){
        g_form.disableAttachments();
    } else {
        g_form.enableAttachments();
    }
}

 

 

However, It doesn't work.

I would appreciate it if you could answer.

1 ACCEPTED SOLUTION

Hi 

Sorry for the script above, please try with this - 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    //var checkValue = g_form.getValue('state').value;
    if (newValue == 7)//check for Closed state backend value{
        g_form.disableAttachments();
    } else {
        g_form.enableAttachments();
    }
}

 

Regards

Omkar Mone

View solution in original post

19 REPLIES 19

AbhishekGardade
Giga Sage

Hello SS,

Create onChange Client script on state field and add below code:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 

    alert(newValue); 

   // Here 7 is the value for closed. Change as per the value you have for closed

    if (newValue== "7"){

        $('header_add_attachment').hide();
    }
}

 

Make sure you set ISOLATED FIELD= FALSE (UNCHECKED). 

find_real_file.png

NOTE:  New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false.

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade

Thank you for your reply.

Sorry for the lack of explanation.

I would like to apply the client script to case tickets.

Therefore,  the value should be 3,but even if  I changed this value to 3, the attachment icon didn't hide.

Can you show your complete client script form? I have test on my instance and its working

Make sure you set ISOLATED FIELD= FALSE (UNCHECKED).  ISOLATED FIELD is not available on form , you need to add it and check it. or on list view you can set it to false

Thanks,

Abhishek Gardade

 

Thank you,
Abhishek Gardade

I've already confirmed that the isolated field is unchecked.

The client script is below.

find_real_file.png

Can you give me access of your instance if it is your personal instance?

Thanks,

Abhishek Gardade

Thank you,
Abhishek Gardade