- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
04-07-2022 05:31 AM - edited 11-14-2023 09:29 AM
This can be achieved by writing any one of the catalog client scripts as shown below:
A) Configure OnSubmit catalog client script as below:
function onSubmit() {
var numberofemployees = g_form.getValue('how_many_employees_select_box'); //Read the select box variable
if (numberofemployees == "7")//Check your variable choice condition as per the requirement
{
try {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert(getMessage('You must attach the completed form before submitting this request.'));
return false;
}
} catch (e) { //For HR Service Portal
var count = getSCAttachmentCount();
if (count <= 0) {
getMessage('You must attach the completed form before submitting this request.', function(msg) {
alert(msg);
});
return false;
}
}
}
}
B) Configure OnSubmit catalog client script as below:
function onSubmit() {
var condition = g_form.getValue('request_related');//Get the value of the catalog variable
if (condition == 'ABC') // Specify the variable choice value condition
{
var countRequired = 2; // define the total no.of attachments to be attached before submit
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;
}
}
}
}
Hope you will find it as helpful. Don’t forget to Mark it Helpful and Bookmark article so you can easily find on your profile.
Thank you,
Dinesh Kumar Raghu,
Capgemini India Pvt Ltd.
GmailID : dineshkumar.raghu9426@gmail.com
- 8,726 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
to let you know the best practice is avoiding DOM manipulation techniques.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Rather than doing a nasty DOM manipulation, it is much better to use a variable of type Attachment, which can be made visible/hidden and mandatory/optional with a simple UI policy. No coding is needed at all.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Slava Savitsky As of now the attachment variable only allows one attachment, which is not ideal sometimes :'(