How Make attachment mandatory using Script and it should be work Both in Native UI and Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2024 12:09 AM
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.
It was showing error in backend
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2024 12:24 AM - edited ā12-19-2024 12:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2024 12:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2024 12:56 AM
Hi @Anand Kumar P ,
Can you please give the context over "window" keyword??
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2024 02:27 AM
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