Pop-up window with Menu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2012 02:38 PM
Okay, so I need to create a client script that runs on change. This would run on the Change Request and auto-populate a field on change from the CMDB.
Right now i just reference the field as the field can only have one group in it, and then the group is pulled in as an approval group. Works great right now.
The problem now is that I have some apps that might need multiple groups in the group field on the CI, and then the customer on the change would choose the particular group for that change. So basically i've created a glide-list on the CI that can contain an array of groups. Now what i'm trying to do is write a client script on the change that would run when the CI on the change was changed. The script will set the group field on the change automatically if there is only one group in the glide_list (i already have this figured out).
Now the hard part that i've yet to figure out, if there is more than one group in this field on the CI, i want to present a pop-up to the customer where they can have a menu and choose exactly and only one of the results from the menu, which would be populated from the fields in the glide_list on the CI. I have most of this figured out, the part I'm missing though is building the javascript pop-up and the menu and setting values to the menu.
Does anyone have any suggestions here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2012 04:23 PM
What you could do is something like this onChange after an if statement determining there is more than 1.
CAUTION: This solution is not documented on the wiki and will not be supported by technical support:
var ret = "sys_idIN" + 'your , seperated list of group sys_ids';
reflistOpen('incident.assignment_group', 'not', 'sys_user_group', null, null, null, ret);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2012 10:02 AM
Okay so this works AWESOMELY!!! (in firefox). In IE the pop-up window opens and then closes immediately.
Below is the code i'm using in an onChange client script:
var list = g_form.getReference('cmdb_ci').u_bus_group.toString();
var array = list.split(",");
if(array.length > 1){
var ret = "sys_idIN" + g_form.getReference('cmdb_ci').u_bus_group;
reflistOpen('change_request.u_bus_approver', 'not', 'sys_user_group', null, null, null, ret);
} else {
g_form.setValue('u_bus_approver', g_form.getReference('cmdb_ci').u_bus_group);
}
So basically if there is only one group in the u_bus_group field on the CI, then i just set the u_bus_group field on change to that group. however, if there are more than one, then i present the pop-up window and the user clicks on it and then it sets the value of the one they click on the the u_bus_approver field on change. This is EXACTLY what I wanted, and thanks!
The only thing now is that IE is the only approved browser, and unfortunately the pop-up seems to exit before it can be drawn and used in IE. Any ideas???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2012 01:19 PM
FYI Works in Chrome too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2012 01:22 PM
That's disappointing 😞
I reproduced the issue you are seeing and don't have a high level of confidence that refListOpen() is going to work here.
I've been able to determine that the issue is with the trigger being an onChange script. If you do an onLoad script it works fine. I even tried some things like defining a function as a Global UI Script and calling this from the client script, but the issue still happens.
Here's what I think your options will be:
If it's acceptable to display an icon next to either the cmdb_ci or assignment group field, you can create a formatter that will invoke the refListOpen onClick. You could do something like an Alert to let the user know that more than 1 selection is available.
With this same Alert functionality, you could also just use an advanced reference qualifier on the group field.
If you need to have this prompt onChange then:
Look at creating a UI Page that you call via GlideDialogWindow - This is also not documented, so use at your own risk.
Still thinking and I will let you know if I think of something else.