Making an attachment mandatory in a catalog task

gnunez
Kilo Guru

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:

find_real_file.png

Thanks in advance!!

AnotherNOWDev
Tera Expert

Hello Grace,



This is a pretty good post about it, maybe it can be what you're looking for.


How to Make Service Catalog Attachments Mandatory in ServiceNow | SN Commander



Hope it's useful


I'm getting an invalid update error .... Match not found, reset to original

Hi John,

In current releases code is not longer needed to make this happen.

There is a new variable type called 'Attachment' which you can use and make it mandatory.

Let me know if this helps. (:

nayanawadhiya1
Kilo Sage

Hey Grace,



Try this -


  1. var sys_id = gel('sys_uniqueValue').value;      
  2. var attachment = new GlideRecord('sys_attachment');      
  3. attachment.addQuery('table_name','sc_task');  
  4. attachment.addQuery('table_sys_id',sys_id);      
  5. attachment.query();  
  6. if (!attachment.next()) {      
  7.       alert ('Attach an attachment.');      
  8. }