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

Hi Murthy,

Im writing code on RFC application.

 

Regards,

Balaji

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello Balaji,

I have tried on my system and its working fine for me, you have to use onsubmit client script on table, as below 

function onSubmit() {


var inc_sys_id= g_form.getUniqueValue();
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", inc_sys_id);
gr.query();

if (!gr.next()) {
alert("You must attach a form before submitting this request.");
return false;
}

}

find_real_file.png

Please mark correct if its working fine for you 

Thanks

Hi Chetan,

Pls find below screen shot and let me know where i did mistake.

find_real_file.png

find_real_file.png

Regards,

Balaji

 

Hello Balaji,

did you get chance to try this it will help you please try once 

Thanks

Kieran Anson
Kilo Patron

Use a before business rule with a condition of !current.hasAttachments(). If the condition fails you can abort with an error message. This saves needing to use a client script that is not isolated (isolate checkbox unticked) or manipulating the DOM which is not recommended.