- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:13 AM
Hello all,
So in a catalog item I created there are attachments that need to be mandatory based on the catalog tasks in the workflow. In the request the first catalog client script works correctly, but the other ones I created for the catalog tasks don't show and instead shows the initial attachment. It basically asks to attach the same attachment over and over again.
Does anyone know how I can make it mandatory only on specific catalog tasks. I already tried checkmarking "Apples on Catalog Tasks" and that didn't work.
This is what I have for the one that does work but keeps showing repeatedly:
Thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:11 PM
Hi Grace,
An update on my existing post, you can use Glide Aggregate on Server side which is a Best Practice for better System Performance rather than using Glide Record on Client Side. Write an Before Insert/Update Business Rule on Catalog Task Table as below:
Condition: You can specify the Catalog Item for which you want to configure this validation by dot walking as mentioned below:
Select "Show Related Fields" option from the filter condition first and then dot walking as "Request Item-->Requested Item fields"
Post which you can select the field as "item" is "Your Item Name" as shown below:
Script:
(function executeRule(current, previous /*null when async*/) {
var att = new GlideAggregate('sys_attachment');
att.addAggregate('COUNT');
att.addQuery('table_name', current.getTableName());
att.addQuery('table_sys_id', current.sys_id);
att.query();
var count = 0;
if (att.next()) {
count = att.getAggregate('COUNT');
if (count<1) {
gs.addInfoMessage("Please attach Attachment");
current.setAbortAction(true);
}
}
})(current, previous);
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 11:57 AM
you haven't write the code in between function -
function onSubmit(){
//here paste the code
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 12:04 PM
I noticed that right after I had replied. I added it and tested and still doesn't ask for an attachment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 12:12 PM
Have you check ed applies on catalog tasks??
0r share your full client script screenshot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:36 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 02:51 PM
we use following script
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 be sure to attach all required documentation prior to submitting your request");
return false;
}
} catch(e) {
if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please add the required attachment before submitting this request.');
return false;
}
}
}