Show/Hide attachment icon in the Incident form - in the email template

Chaithra Srini1
Mega Expert

Hi everyone,

We have one UI script which hides the 'attachment' icon in the email template of Incident form. The attachment icon and UI script written to hide it are shown below.

Is there any way to hide that attachment icon from RITM and sc_task table and keep it visible in only 'incident' table. Please help me with your insights. Thanks in advance.

- Navigate and open any incident form > Click on 'More Options' (3 dots)
- Click on 'Email template' icon
- In the template form, you will see the 'attachment' icon. 

find_real_file.png

UI script written to hide that icon.

find_real_file.png

Is there any way that we can hide it only for Incident form/table? Please advise.

FYI, I am trying below code to incorporate the requirement, but it is not working

find_real_file.png

Regards,
Chaithra

1 ACCEPTED SOLUTION

Hi Chaithra,

So you have reverted it to previous version and have not kept the code to get sysparm_table?

Are you running this in scoped app?

try this once instead of above code given by me

var gURL = new GlideURL();
gURL.setFromCurrent();
var tableName = gURL.getParam("sysparm_table");

if(tableName == 'sc_req_item' || tableName == 'sc_task'){

addLoadEvent(function() {
if (window.g_user == undefined) {
return;
}
try{
if(document.URL.indexOf('email_client.do') >= 0) {
$j(document).ready(function(){
$j('#attach_button').hide();
});
}
}
catch(e){
alert(e);
}
});

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Chaithra Srini1
Mega Expert

Hi Ankur,

Yes, It was working for other tables after adding that code. But when we open any form or any application module from the navigation bar it was opening in a new tab and hence we reverted those changes back to previous code. Is there any way to fix those impacts? Please advise

Thanks,
Chaithra

 

Hi Chaithra,

So you have reverted it to previous version and have not kept the code to get sysparm_table?

Are you running this in scoped app?

try this once instead of above code given by me

var gURL = new GlideURL();
gURL.setFromCurrent();
var tableName = gURL.getParam("sysparm_table");

if(tableName == 'sc_req_item' || tableName == 'sc_task'){

addLoadEvent(function() {
if (window.g_user == undefined) {
return;
}
try{
if(document.URL.indexOf('email_client.do') >= 0) {
$j(document).ready(function(){
$j('#attach_button').hide();
});
}
}
catch(e){
alert(e);
}
});

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Chaithra Srini1
Mega Expert

Hi Ankur,

I have tried this in our instance and it workes perfectly fine. I don't see any impacts now. Thanks a lot for your help.

Regards,

Chaithra

 

 

Chaithra Srini1
Mega Expert

Hi Ankur,

Can you please explain me what the below code does actually?

var gURL = new GlideURL();
gURL.setFromCurrent();
var tableName = gURL.getParam("sysparm_table");

Thanks in advance! 🙂 

Regards,

Chaithra

 

 

Hi Chaithra,

The script uses GlideURL class provided by ServiceNow and then uses getParm() function to get value of parameter present in the url

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_GURL-GlideURL_S

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader