Attachment mandatory script in UI policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2021 10:54 PM
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
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 01:05 AM
where should i give my table name?
i don't have any column or check box for attachment mandatory. I just need to know whether attachment is exist or not when i press the button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 01:17 AM
Hi balaji,
Is attachement mandatory for form or catalog item ??
If it is for catalog item you need to write catalog client script (ON submit)
PFB:
function onSubmit()
{
//Type appropriate comment here, and begin script below
var countRequired = 2;
if(window == null)
{
// portal
if(this.document.getElementsByClassName('get-attachment').length != countRequired)
{
alert('You must add 2 attachments before submitting this request.');
return false;
} }
else
{
// native view var length = $j("li.attachment_list_items").find("span").length;
if(length != countRequired)
{ alert('You must add 2 attachments before submitting this request.');
return false;
} } }
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 01:26 AM
Thanks Mutrhy for quick reply.....! but i need for form not for catalog item.
if not possible with UI Policy pls let me know by which component code i can achieve this?In the above screen when i click on save it should check attachment is attached or not if not it should throw and error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 01:31 AM
HI balaji
It should not be possible to through UI policy..
As per your screen shot if we click on save button we need to make attachment mandatory right??
If so we need to write UI actions..
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 01:34 AM
Hi balaji,
please write this on submit client script and let me know if you found any issues..
function onSubmit() {
var cat_id = g_form.getValue('sysparm_item_guid');
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("You must add an attachment before submitting this request.");
return false;
}
}
Thanks,
Murthy
Murthy