- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 12:06 AM
Can anyone advise me of an alternative for gel('sysparm_item_guid').value code? Need to make the attachment mandatory in SERVICE PORTAL var sid = gel('sysparm_item_guid').value; var gr_at = new GlideRecord("sys_attachment"); gr_at.addQuery("table_name", "sc_cart_item"); gr_at.addQuery("table_sys_id", sid); gr_at.query(); var res = gr_at.next(); if (!res) { alert("You must have an attachment to submit."); return false; } Appreciate the help. Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 06:16 PM
Hi Bryan,
Please find this thread which is equivalently helpful making Attachment mandatory on submission of the item in both Service Portal and Scoped Application: Require attachment for catalog item in Service Portal
You need to create a new UI Script in Global Application scope and call that in your onSubmit Catalog Client Script. In your case the scripts are given below. You need to leverage your existing logic in the Catalog Client Script.
UI Script:
API Name:GlobalCatalogItemFunctions
Script:
function getSCAttachmentCount() {
var length;
try {
length = angular.element("#sc_cat_item").scope().attachments.length;
} catch(e) {
length = -1;
}
return length;
}
onSubmit Catalog Client Scrip (in Global Scope):
function onSubmit() {
try { //Works in non-portal ui
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('Please attach atleast one attachment to proceed');
return false;
}
}
catch(e) { //For Service Portal
var count = getSCAttachmentCount();
if(count <= 0) {
alert('Please attach atleast one attachment to proceed');
return false;
}
}
}
I hope this helps. Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 12:28 AM
Hi Bryan,
Where are you using this script, is it onSubmit script on some catalog item ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 04:39 PM
Is this working on Service Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 05:05 PM
yes onsubmit. this is working on CMS but not in service portal. do you have any alternative? Thank you for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2017 12:41 AM
Hi Bryan,
I faced similar issue and found the solution here - Catalog service making Mandatory Attachment both application and SP
This might help you in making attachments mandatory,