How to check whether the user has added an attachment while requesting from catalog

Community Alums
Not applicable

Hi All,

 

I have to validate whether user has added an attachment or not before allowing him to submit a request.Please help me if any of you have done a similar kind of implementation.

 

Regards,

Kirti

1 ACCEPTED SOLUTION

Harish Murikina
Tera Guru

Write the below on submit script



function onSubmit() {




  var attachmentList = gel("header_attachment_list_label");



  if (attachmentList)


  {


  if (attachmentList.style.visibility == "hidden" || attachmentList.style.display == "none")


  {


  alert("Please attach the required file.");


  return false;


  }


  }


}




Regards,


Harish.


View solution in original post

17 REPLIES 17

poyntzj
Kilo Sage

Try a client script that will look at the sys_attachment table and see there is a record in that table for your current record



var gr = new GlideRecord('sys_attachment');


gr.addQuery('table_sys_id',g_form.getUniqueValue());


gr.query();


if (gr.next())


        // we have record


else


        // No record - alert user


        // do something else


Community Alums
Not applicable

Using Gliderecord is not preferable clientside So i avoided this approach


Anurag Tripathi
Mega Patron
Mega Patron

You want this on a catalog item or RITM Form.


If its on the FORM then its better to have a business rule on attachment table


When -   After


Condition - (with conditions so that it only runs for you and not other tables)


Insert



Script



  1. var gr = new GlideRecord('sc_req_item');  
  2. gr.addQuery('sys_id',current.table_sys_id);  
  3. gr.query();  
  4. if (gr.next())  
  5. {
  6. gr.work_notes="/* whatever you want to print, attachment name may be*/"
  7. gr.update();
  8. }
-Anurag