onsubmit client script to check for attachments before submitting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 08:16 AM
Hello Experts,
I need a onsubmit client sprint which should check for attachments if the request_type = grant or modfiy.
system should not allow the request to be submitted until the attachment is attached.
for revoke it should not check for attachment and allow order now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 09:10 PM
Hello,
I'm getting a javacript error on the console. please help.
this is my script
function onSubmit() {
if (g_form.getValue('request_type') == 'grant'); { // This is the field value of the question you want to check
try {
var msg = 'This request requires an attachment. Please review the form and try again.';
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert(msg);
return false;
}
}
//For Service Portal
catch (e) {
var count = getSCAttachmentCount();
if (count <= 0) {
alert(msg);
return false;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 09:41 PM
Heelo Alp,
i'm using this script but getting an error
function onSubmit() {
if (g_form.getValue('request_type') == 'grant'); { // This is the field value of the question you want to check
try {
var msg = 'This request requires an attachment. Please review the form and try again.';
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert(msg);
return false;
}
}
//For Service Portal
catch (e) {
var count = getSCAttachmentCount();
if (count <= 0) {
alert(msg);
return false;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 09:25 PM
Hi @Anubhav Srivas1 ,
Create the catalog client script as below. it will validate for at least one attachment is mandatory before submission of request. Please cross check grant and modify backend values.
function onSubmit() {
if ((this.document.getElementsByClassName('get-attachment').length < 1) && (g_form.getValue('request_type') == 'grant' || g_form.getValue('request_type') == 'modify')) {
alert('Please ensure that atleast 1 attachment required to submit the catalog');
return false;
}
}