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 10:06 PM
Hi,
Please refer below thread, You will get help
If my answer solve your query please mark appropriate response as correct so that the thread will appear as resolved for other users who may have a similar query in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 10:36 PM
i Kajal,
Can you pls help me on the below code.
var inc_sys_id = g_form.getUniqueValue();
alert("test-01....." + inc_sys_id);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "x_inem_rfc_table"); //Table name x_inem_rfc_table
gr.addQuery("table_sys_id", inc_sys_id);
alert("test-02....." + gr);
gr.query();
if (!gr.next()) {
g_form.addErrorMessage('You must add an attachment before submitting this request.');
return false;
}
i use this code in client script for Onsubmit but im getting error message "Submit canceled due to a script error - please contact your System Administrator".
Regards,
Balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 12:01 AM
refer my blog below which would work native + portal
enhance it as per your requirement
Verify Mandatory Attachments Count on Catalog Item
please mark blog as helpful and also bookmark if that helps
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 12:57 AM
Hi Ankur,
I'm working in custom app and extend from task table so i need the attachment script for this either in client script/Business Rule.
Regards,
Balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 01:25 AM
Hi,
then you can have before insert/BR for this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec = new GlideRecord('sys_attachment');
rec.addQuery('table_sys_id', current.sys_id);
rec.query();
if(!rec.next()){
gs.addErrorMessage('Please add attachment');
current.setAbortAction(true);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader