- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 05:46 PM
Hi ,
I have an issue that, In the catalog form , when Line manager is None , when user is going to submit the form it will attachment , as you seen in the below image
Note - If Line manager present it won't ask any attachment, like this we have developed , in the service Portal it is working as excepted .
where coming to snow platform , you can see in the below image , line manager is empty , i have attached an attachment but still form is not able to submit .
Notes - when i didn't select line manager , i didn't shown error i.e If line manager is not listed attachment is mandatory , you can find in 1st image , but in servicenow platform it is not showing .
we are unable to fix this issue , we need help to fix this issue .
@kamlesh kjmar @Saurav11 @Gunjan Kiratkar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 07:37 PM
Hi @nameisnani ,
For DOM reading you must make Isolate script box unchecked in your script(s) as shown below:
Make sure this field is unchecked and your issue will resolve. If this field is not available on your script form, then configure the form layout and bring that field on form OR you can include this field in your list view of script and select false for it as shown below:
I hope this helps.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:30 PM
check my blog on how to validate attachment. Enhance it as per your case.
It works in both native + portal
Verify Mandatory Attachments Count on Catalog Item
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 11:31 PM - edited 11-20-2022 11:33 PM
The format should be as below:-
function onSubmit(){
if(g_form.getValue('line_manager') == '')
{
//Put all Ankur's article code inside it
}
}
function onSubmit() {
var countRequired = 1;
if(g_form.getValue('line_manager') == '')
{
if (window == null) {
// portal
if (this.document.getElementsByClassName('get-attachment').length != countRequired) {
g_form.addErrorMessage(getMessage('Attachment is Mandatory if Line Manager is not Auto Populated'));
return false;
}
} else {
// native view
var length = $j("li.attachment_list_items").find("span").length;
if (length != countRequired) {
g_form.addErrorMessage(getMessage('Attachment is Mandatory if Line Manager is not Auto Populated'));
return false;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 07:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 07:50 PM
@kamlesh kjmar after making also same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 07:53 PM
@nameisnani , make sure you unchecked isolated script for all scripts in which this.document.getElementByClassName is used.
After that also if you get the error messsage, share the screen shot of error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 07:56 PM
After making isolated script false
after attaching attachement also not able to submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:13 PM
I do not see any other issue, however the class name which you are using I do not see that existing. In your onSubmit client script, try replacing your this.document.getElementsByClassName('get-attachments') with below line and see if it works
document.getElementsByClassName("attachment_list_items")
Regards,
Kamlesh