- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 01:35 PM
You can write this in display business rule and then set them mandatory to false in your onload client script
var mandatory_fields=[];
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID('put your request item sys_id');
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if(vs.get(i).mandatory==true){
mandatory_feilds.push(vs.get(i).getName());
}
}
g_scratchpad.mandataoryArray=mandatory_fields;
In your client script use this
for (i=0; i<g_scratchpad.mandatoryArray.length;i++){
g_form.setMandataory(g_scratchpad.mandatoryArray[i],false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2016 09:57 AM
Abhinay,
This is definitely helpful but it's not grabbing the actual variables for me. It's missing a couple for me (2 drop downs and a string)
Is there any limitations with your script? For example, does it ignore variable sets?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2016 10:18 AM
Nope, it should have grabbed all the variables which have mandatory set to true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2016 11:07 AM
Ah, I have found the issue.
This only works for variables that are checked off as mandatory because its checking at display. The ones I need to change are being set to mandatory by a UI policy. Variables that are not mandatory by default will not work with this solution.
I'll see if I can re-work this to check after the UI policy.
Thanks for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2016 11:15 AM
Ahh.. I do not think this will work with a display business rule. Since
display business rule is triggerred before a record is actually displayed.
I will recommend to use a glideajax in a client script and put the server
side script in a script include.
On Monday, July 25, 2016, nickmayo <community-no-reply@servicenow.com>