- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 11:27 PM
There are some software's in software table for which if user selects that particular software in portal, then attachment must be mandatory.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 12:22 AM
Hi,
you can refer my blog which works in native+portal; enhance it as per your requirement
If it helps please mark it helpful and also bookmark it
Verify Mandatory Attachments Count on Catalog Item
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 11:51 PM
Hello Ramya,
Making the attachment mandatory based on the specific selection, It won't be possible without DOM manipulation(Not Recommended). We can achieve by writing an onSbumit() client script for that field. Please find the code below
function onSubmit() {
if (g_form.getValue("Field_value") == 'valueCheck') { //get the value
try {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert("Please attach before submitting the request.");
return false;
}
} catch (e) {
if ((this.document.getElementsByClassName('get-attachment').length == 0)) {
alert('Please attach before submitting the request.');
return false;
}
}
}
}
Mark it helpful or correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 01:35 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits Others.
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 02:22 AM
Hello Ramya,
Happy to know, you got the solution.
Mark my answer correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 12:00 AM
Hello @Ramya
Try like below..tested..working...
Note : Make sure to set Isolate script as false
function onSubmit() {
var getValue = g_form.getValue('software_fieldname');
if (getValue == 'software name 1' || getValue == 'software name 2') {
if (this.document.getElementsByClassName('get-attachment').length == 0) {
g_form.addErrorMessage('Please Attach a file');
return false;
}
}
}