Make an attachment mandatory using select box choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 07:27 AM
Hi
I'm building a form to do with budgets, so there is a requirement that when an option is selected from a select box it is then mandatory to attached a exemption word docx form to the form before it can be submitted.
So if the user chooses "over £1000" I need a text box to appear underneath and then the attachment option which is on all forms needs to be then mandatory.
I can't seem to work out how to do this? Would a UI policy do it?
Cheers
Roly
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 07:51 AM
the below script should work fine in both native and portal
Ensure the following
- Isolate Script is set to false on this onSubmit catalog client script
- This field is not on form but from list you can set it to false
- This field is by default true
Script Below:
Ensure you use valid variable name and the choice value here for Over £1000
function onSubmit() {
//Type appropriate comment here, and begin script below
var value = g_form.getValue('variableName'); // give valid variable name here
// give proper choice value for Over £1000
if(value == 'Over £1000'){
if(window == null){
// portal
if(this.document.getElementsByClassName('get-attachment').length == 0) {
alert('You must add attachment before submitting this request.');
return false;
}
}
else{
// native view
var length = $j("li.attachment_list_items").find("span").length;
if(length == 0){
alert('You must add attachment before submitting this request.');
return false;
}
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2020 11:26 PM
Hope you are doing good.
Let me know if that answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader