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!!

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

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:



find_real_file.png



Select "Show Related Fields" option from the filter condition first and then dot walking as "Request Item-->Requested Item fields"


find_real_file.png



Post which you can select the field as "item" is "Your Item Name" as shown below:



find_real_file.png



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);





find_real_file.png



find_real_file.png


Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

21 REPLIES 21

Nayan,



Do I need to replace some of the values to my own? If so which ones?



Thanks!


no need to change anything!!!


It didn't work. Do you think its because I'm not specifying a value? Since I'm trying to trigger it in a catalog task it needs something to tell it when right?



Also, for "Type" I took off the onSubmit and put None instead, don't know if that makes a difference.



Thanks,


Grace


write "return false;" after alert(); And Client script should "onSubmit" Client script


It says syntax is OK but there is an error saying invalid return. I also added onSubmit



Here is what it looks like:


find_real_file.png