Attachment mandatory script in UI policy.

Balaji3
Kilo Contributor

Hi Techies,

I need help on coding part.....

i need script for attachment mandatory through UI Policy for my custom application when user raise a ticket for servicenow Quebec release.

Thanks in advance.....!

Regards,

Balaji

 

29 REPLIES 29

can you pls share the code if you have handy.

 

 

Regards,

Balaji

Hi balaji,

dont write UI actions

try the above on submit() client script.

 

Thanks,

Murthy

Please mark my answer correct/ helpful if its solves your query..

Thanks,
Murthy

Hi Murthy,

i wrote below code in client script onSubmit type.

function onSubmit() {
//Type appropriate comment here, and begin script below
var cat_id = g_form.getValue('sysparm_item_guid');
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "x_inem_rfc_table"); //My Table name x_inem_rfc_table
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("You must add an attachment before submitting this request.");
return false;
}

}

But getting below error message.

"Error MessageSubmit canceled due to a script error - please contact your System Administrator"

HI balaji 

Sorry for confusing 

please try this

hope it helps you for sure.

Its working for me...

PFA

find_real_file.png

Thanks,

Murthy

 

Thanks,
Murthy

Hi Murthy,

getting this error again "

MessageSubmit canceled due to a script error - please contact your System Administrator
".find_real_file.png
First rectangular is my condition means if urgency is 'Expedite it should attach 2 attachments if 'Routine' it should attach one attachment.
Second rectangular is the code which you suggested to me.
 
Regards,
Balaji