Unable to validate attachments for two File Attachment fields using onSubmit Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi All,
I have a requirement in Claim table.
In this form I have the following fields:
Booking Reference – Reference field (Mandatory)
Upload Boarding Pass – Type: File Attachment
Upload PIR Form – Type: File Attachment
Requirement
When the user submits the form, they must upload at least one attachment in either Upload Boarding Pass or Upload PIR Form field.
Expected behavior:
If both fields have no attachment → Form submission should be blocked and an error message should appear:
"Upload Boarding Pass or PIR form (any one is mandatory)."If either one of the fields has an attachment → Form should submit successfully.
Issue I am facing:
I tried implementing this using an onSubmit Client Script.
The validation message is displayed when no attachment is added, which is correct.
However, after the message appears:
When I try to click on the attachment field to upload a file, it does not allow me to add the attachment.
Sometimes clicking the field does nothing or does not open the attachment dialog.
Because of this, the user cannot upload the attachment after the validation message appears.
Question:
What is the best practice in ServiceNow to validate that at least one attachment is uploaded between two File Attachment fields?
Is onSubmit Client Script the correct approach for this requirement?
Tried with,
Any suggestions or examples would be very helpful.
Thanks in advance.
Spandus
