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.

Need to accept only PDF format.

pawank2
Tera Expert

HI Team,

 
I am working on a requirement where I need to create a new field type(file attachment) and which need to accept only pdf format.
 
Can someone please help?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eew-ijgp-qke
1 ACCEPTED SOLUTION

anshul_goyal
Kilo Sage

Hello,

You can create onBefore insert/update Business Rule to accept PDF File format.
 
Try below script:
Table: Your_Table_Name
Condition: File Attachment changes
var attachRef = new GlideRecord('sys_attachment');
if (attachRef.get(current.u_pdf_attachment)) {
var fileType = attachRef.getValue("content_type");
if (fileType.toString() != "application/pdf") {
gs.addErrorMessage("Please attach PDF File Format.");
current.setAbortAction(true);
}
}


Please mark my response as Accepted and Helpful for future references.

Thanks

 

View solution in original post

1 REPLY 1

anshul_goyal
Kilo Sage

Hello,

You can create onBefore insert/update Business Rule to accept PDF File format.
 
Try below script:
Table: Your_Table_Name
Condition: File Attachment changes
var attachRef = new GlideRecord('sys_attachment');
if (attachRef.get(current.u_pdf_attachment)) {
var fileType = attachRef.getValue("content_type");
if (fileType.toString() != "application/pdf") {
gs.addErrorMessage("Please attach PDF File Format.");
current.setAbortAction(true);
}
}


Please mark my response as Accepted and Helpful for future references.

Thanks