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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Not sure if you have the table available, like your doing with g_form.getTableName(). Though, in the URL, sysparm_table is available! Would this help?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks Mark for your insights. Yes, sysparm_table which is available in the url helped.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chaithra,

In the url you have sysparm_tabl; use that and hide it if incident or sc_task table

var name = 'sysparm_table';

var tableName = '';

var url = document.URL.parseQuery();
    if(url[name]){
        tableName = decodeURI(url[name]);
    }

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

// code to hide that

}

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,

This worked!! Thanks a lot for your help and insights 🙂

 

Pasting the code below, so it could be useful for anyone who is looking for it

//Updated by Chaithra on May 13th, 2019 to make this attachment clip icon visible only in the Incident form

var name = 'sysparm_table';
var tableName = '';
var url = document.URL.parseQuery();
if(url[name]){
tableName = decodeURI(url[name]);
}

// Code to hide the attachment icon in ritm and task forms

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);
}
});

}

 

Regards,

Chaithra