Attachment mandatory in change request

svizcaino
Kilo Contributor

Hi guys, i was wondering if someone can gave me some advice of how to make mandatory the attachments before the submit in the change request form. Thanks in advance

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Try an onSubmit client script. Something like this:



function onSubmit(){  


  var attachment = new GlideRecord('sys_attachment');      


 


  attachment.addQuery('table_name','change_request');  


  attachment.addQuery('table_sys_id',current.sys_id);      


  attachment.query();  


 


  if(!attachment.next()){      


      alert ("Please include attachment");      


  return false;


  }


}



Cheers,



Tim


View solution in original post

7 REPLIES 7

Mihir Mohanta
Kilo Sage

You can do it in server sided without using GlideRecord query.



Please go through below thread.



Making attachment mandatory in change request ?



Thanks,


Mihir


ankitbadola
Giga Expert
  1. Create a business rule ...before one
  2. if (current.hasAttachments() == true)      
  3. {      
  4. // do something
  5. }      
  6. else      
  7. {      
  8. current.setAbortAction(true);  
  9. //do something
  10. }      

PS: Hit like, Helpful or Correct depending on the impact of the response


Yash Agrawal1
Tera Guru

Hi  svizcaino

First of all current object is not used in client script so please first at least try all those client script on your instance then mark it correct.

so the correct c;ient script is 

function onSubmit()
{

var gr = new GlideRecord('sys_attachment');

gr.addQuery('table_name','change_request');

// gr.addQuery('table_sys_id',5e43d262e1f1330078502406b63333d0);

gr.query();

if(!gr.next())
{

alert ("Please include attachment");

return false;
}


}

 

I am also attaching Screenshot for your reference.

find_real_file.png

If your work is completing by using my client script please MARK CORRECT/HELPFul to my answer.

Regards

Yash.K.Agrawal