Best Practice for using a select box variable twice for dynamic purposes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have created an approval variable for a Service Catalog Request which essentially asks on the catalog item view if an approval has taken place prior to this request being submitted. The options are Not Yet Requested, Approved, and Rejected. If the user selects Not Yet Requested, then after the request is submitted then an approval is requested via a catalog task. On that catalog task the same variable shows up but is cleared and dynamically hides the Not Yet Requested option and instead offers Approved or Rejected.
Questions:
Is this variable being used twice best practice or should it be split?
There was also a concern about DOM manipulation which I am unsure about. Could a user use DOM manipulation to show the Not Yet Requested option on the variable in the catalog task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
There should be no need to DOM manipulation. Client script using g_form.addOption and g_form.removeOption can be used to show and hide options in a dropdown.
My question is why is this even a variable. Most users will just select approved to try and get there request done as soon as possible. A better way to do it would be to remove the variable and always go for approval.
As for using it twice I'm not sure what you mean. Having the variable editable on the catalog task is not using it twice but just using the same variable on the catalog task as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Thanks Brian!
I appreciate your input, yes I have a client script that is handling it. Using the method you described but the concern was that someone could show those options on the variable even though they are hidden.
The approval route does make sense but currently a team follows up on the approval. It's tedious but its the route required for the now as the company gets more acquainted with ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
This is the onLoad script that is being executed for the catalog task if Not Yet Requested is selected during the initial submission. This script removes the option for the team to either select Approve or Reject.
function onLoad() {
//Type appropriate comment here, and begin script below
var v = g_form.getValue('vp_director_approved');
if(v == '' || v == 'not_yet_requested')
{
g_sc_form.removeOption('vp_director_approved','not_yet_requested');
g_form.setMandatory('vp_director_approved',true);
}
}