How to check strings in a text file attached during a catalog order.

Ryota
Tera Guru

When ordering a catalog item, I need to attach a text file. Is there a way to prevent the attachment if the file contains specific strings (such as 'delete' or 'change')? I would like to apply this rule to a specific catalog item only.

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Ryota 

it's difficult to achieve this with OOTB paper-clip icon and onSubmit script

Approach

1) create attachment type variable and only allow txt file using variable attributes

allowed_extensions=txt

2) then write onChange catalog client script on that variables and use GlideAjax, send the sysId of the variable value, then query sys_attachment and read the text file

see if this link helps and enhance your script, I shared solution on how to validate file when file is attached to attachment variable

Validate Excel Data and populate in MRVS 

Validations on MRVS - validate Employee ID 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @Ryota 

 

It is not feasible. Before Insert , you can validate Filename/File extension But not File content.

 

So Alternative could be ask business to maintain some naming convention, so that they can add "Delete" /"Update" keyword with file name itself.

 

So that you can write your rule/script to prevent the attachment.

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti