How to validate a CSV file upto 10KB or limit the number of rows upto 20 records in a catalog item?

User205031
Tera Contributor

Hi All,

I have a requirement where I have to measure the size of the attachment while submitting the catalog item.

The attachment should not be more than 10 KB. If it is more than 10 KB then it should throw an alert and abort the action. Hence user will not be able to submit the catalog item with that file.

 

or, is there any way to check the number of rows in the CSV file up to 20 records? If there is more than 20 records it will abort the action and user wont be able to submit the cat item.

 

Kindly help how to achieve this requirement.

 
1 ACCEPTED SOLUTION

@User205031 

you should use Attachment type variable with this variable attribute

Also check this link for onchange client script to validate the rows, you will have to enhance it by using CSV Parser

Validating an attachment variable 

Check docs for more help

Types of service catalog variables

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

6 REPLIES 6

User205031
Tera Contributor

Hi @Ankur Bawiskar , do you have any suggestions how to proceed?

@User205031 

you should use Attachment type variable with this variable attribute

Also check this link for onchange client script to validate the rows, you will have to enhance it by using CSV Parser

Validating an attachment variable 

Check docs for more help

Types of service catalog variables

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar ,

 

Is it not possible to check with the OOB attachment icon that is present?

 

Thanks!

@User205031 

it's challenging as the record in sys_attachment gets created each time with different cart sysId which we don't know how is generated

So I will suggest to use attachment type variable and use the OOTB variable attributes and no scripting will be required

I believe I have answered your question

If my response helped please mark it correct and close the thread so that it benefits future readers.

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