How Make attachment mandatory using Script and it should be work Both in Native UI and Portal?

Raviteja24
Tera Contributor

Hi,

I have created a onSubmit client script which is used to make attachment mandatory . But , it was working in portal and it is not working in backend.


Raviteja24_0-1734595647312.png



It was showing error in backend 

Raviteja24_1-1734595735450.png

Thanks,

5 REPLIES 5

Anand Kumar P
Giga Patron
Giga Patron

Hi @Raviteja24 ,

 

you can use below script onSubmit client script and make the isolate checkbox in client script make it false.

 

function onSubmit() {

var countRequired = 1;

if(window == null){
// portal
if(this.document.getElementsByClassName('get-attachment').length != countRequired) {
alert('You must add attachments before submitting this request.');
return false;
}
}
else{
// native view
var length = $j("li.attachment_list_items").find("span").length;
if(length != countRequired){
alert('You must add attachments before submitting this request.');
return false;
}
}
}
}

 

 

If my response helped, please mark it as the accepted solution āœ… and give a thumbs upšŸ‘.
Thanks,
Anand

Hi @Anand Kumar P ,

I'm seeing same error in backend.

Raviteja24_0-1734598487782.png

Thanks,

 

Hi @Anand Kumar P ,

Can you please give the context over "window" keyword??


Thanks,

Hi @Raviteja24 ,

If the user want to setup client script run both in desktop and service portal, to differentiate it  

 

if(window == null){ // it will check if script is running on serviceportal.

 

If my response helped, please mark it as the accepted solution āœ… and give a thumbs upšŸ‘.
Thanks,
Anand