How to validate attachment to accept only JPG format on record producer form

Are Kaveri
Tera Contributor

Hi 

 

Is there any way to add validation for Attachment to accept only JPG format on Record producer variable?

 

I have a requirement for making a variable of type file attachment.

I need to validate whether the attached file is in JPG format

 

Please help me.

1 ACCEPTED SOLUTION

Uday Soni05
Tera Guru

Hi @Are Kaveri ,

You can create Attachment Type Variable and navigate to Type Specification Section and populate

Variable Attribute as allowed_extensions=jpeg or if you want any other extension as well you can do it like this allowed_extensions=jpeg;pdf;pptx

Screenshot 2023-10-12 at 11.30.29 AM.png

And then you can validate it on portal

If u try to attach attachment with other extension it will not get attached and it will give Field error msg below the field

Screenshot 2023-10-12 at 11.40.41 AM.png

 If you attach the valid extension file

Screenshot 2023-10-12 at 11.41.43 AM.png

 I hope it will help you

Let me know if you any questions

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Uday

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Hi,

 

Below link will help you achieve your requirement. 

 

https://www.servicenow.com/community/developer-articles/to-allow-attachments-of-specific-file-type-o...

 

Let me know if you have further questions.

 

Please mark this comment as Correct Answer/Helpful if it helped you.

 

Cheers,

Hardit Singh

Hi @Community Alums ,\

the below example community link is for out of box Attachment .

In my case,

 

i have taken the variable of type Attachment.

variable name: Profile picture

type: Attachment

for this particular variable i need to allow only JPG format.

 

how can i validate this scenario?

 

Uday Soni05
Tera Guru

Hi @Are Kaveri ,

You can create Attachment Type Variable and navigate to Type Specification Section and populate

Variable Attribute as allowed_extensions=jpeg or if you want any other extension as well you can do it like this allowed_extensions=jpeg;pdf;pptx

Screenshot 2023-10-12 at 11.30.29 AM.png

And then you can validate it on portal

If u try to attach attachment with other extension it will not get attached and it will give Field error msg below the field

Screenshot 2023-10-12 at 11.40.41 AM.png

 If you attach the valid extension file

Screenshot 2023-10-12 at 11.41.43 AM.png

 I hope it will help you

Let me know if you any questions

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Uday