Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mandatory Attachments on the Record Producer

Community Alums
Not applicable

Hi,

I want to make Attachments mandatory on the record producer (on the servicenow platform, not the portal). 

I have written a client script using DOM. However, thats going to cause updrade issues. Please see the attached screenshot. My question is what is the alternative method? How can I use glideform API? Anyone has working code?

find_real_file.png

 

Thank you

7 REPLIES 7

Service_RNow
Mega Sage

Hi Shabnam,

Please Try to this code :-

  1. var sys_id = gel('sysparm_item_guid').value;          
  2. var attachment = new GlideRecord('sys_attachment');          
  3. attachment.addQuery('table_name','u_custom_table_name');   //my custom table is "u_custom_table_name"  
  4. attachment.addQuery('table_sys_id',sys_id);          
  5. attachment.query();      
  6. if (!attachment.next()) {          
  7.       alert ("PLEASE ATTACH INVOICE.");      
  8.   return false;  
  9. }    

After going throw this Mark it Correct/helpful, if this helps you
Thank you

Omkar Mone
Mega Sage

Hi 

Try this code, sysparm wont work on portal and this will also work on desktop view -

var sysID = g_form.getUniqueValue();          
var attachment = new GlideRecord('sys_attachment');          
attachment.addQuery('table_name','sc_cart_item');
attachment.addQuery('table_sys_id',sysID);          
attachment.query();      
if (!attachment.next()) {          
      alert ("Attachment Required");      
  return false;  
}    

 

Hope this helps.

 

Regards

Omkar Mone

Vishal Khandve
Kilo Sage

Hi,

Please go through the below article-

https://community.servicenow.com/community?id=community_article&sys_id=0f0c5290dbe7f380d82ffb2439961...

 

Thanks,

Vishal Khandve