Difference in the behavior in Service Portal and In ServiceNow Platform

nameisnani
Mega Sage

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 .   

 

SunilKumarPadh_0-1668994686305.png

 

 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 . 

 

SunilKumarPadh_1-1668994870084.png

 

 

@kamlesh kjmar @Saurav11 @Gunjan Kiratkar 

3 ACCEPTED SOLUTIONS

Hi @nameisnani ,

 

For DOM reading you must make Isolate script box unchecked in your script(s) as shown below:

 

kamleshkjmar_0-1669001710575.png

 

 

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:

 

kamleshkjmar_1-1669001866170.png

 

 

I hope this helps.

 

Regards,

Kamlesh

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

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.

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

View solution in original post

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;
}
}
}
}

View solution in original post

32 REPLIES 32

@nameisnani 

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

@Ankur Bawiskar 

Instead of this alert message is that possible to add error message for both native and portal view 

 

SunilKumarPadh_0-1669009319282.png

SunilKumarPadh_1-1669009439282.png

@Ankur Bawiskar 

@nameisnani 

why not

you can use g_form.addErrorMessage('Your Message here') instead of alert

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

Saurav11
Kilo Patron
Kilo Patron

Hello @nameisnani 

 

There are many such syntax which works on portal and not in native UI and vice versa.

 

The article shared by Ankur should work for you. Just use that code and modify it accordingly.

 

Thanks.

@Saurav11 @Ankur Bawiskar 

 

anukur code is worked for me , But there was an small issue , we have faced 

 

u can see in the below image , when line manger listed automatically or manually selected , while submitting the form it won't ask for attachment , after updating with aukur code , 

 

SunilKumarPadh_0-1669012824717.png

 

 

the attachment should show only in when line manager is equal to none 

 

 

this is my pervious code 

SunilKumarPadh_1-1669012913767.png

this anukur code 

SunilKumarPadh_2-1669012933472.png

 

i think in the aukur code we need to give line manager condtion 

 

@Saurav11 @Ankur Bawiskar Please help me