- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 07:35 AM
On a catalog item, I have the User who opens the request auto-populating the "Ask on Behalf of the this User" field.
I then have the Phone field populating with that user's phone number. This is the code I have in the "Default Value" field for Phone number:
javascript: var userPhone; var user = new GlideRecord('sys_user'); if (user.get(gs.getUserID())) {userPhone = user.phone}; userPhone;
I'd like to do something similar for the Manager from the user's record in a field on the catalog item:
javascript: var userManager; var user = new GlideRecord('sys_user'); if (user.get(gs.getUserID())) {userManager = user.cost_center.manager}; userManager;
The difference between the "phone" and "manager" field on the user's record is that the manager field is actually a reference field on the "cost center" table…
Is it possible to dot.walk to that manager field in the Default Value of the Dictionary of the Manager field on the catalog item?
Thanks,
Richelle
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 10:26 AM
Here's how I got this to work.
1. On the catalog item I changed the Manager field type to Lookup Select Box.
Lookup from table: Cost center [cmn_cost_center]
Lookup value field: Sys_id
Lookup lable field(s): manager
Default value: javascript:getCostCenterSysId(getReqfor(gs.getUserID()));
Reference Qualifier: Active = True
2. I also added the Cost Center (cost_center) Reference field to the catalog item:
Reference: Cost center [cmn_cost_center]
Default Value: javascript:getCostCenterSysId(getReqfor(gs.getUserID()));
Reference Qualifier: Active = True
3. For the Catalog Client Script:
Type: onChange
Variable name: cost_center
Script:
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
var gp = new GlideRecord('cmn_cost_center');
var cc = g_form.getValue('cost_center');
gp.addQuery('sys_id',cc);
gp.query();
if(gp.next()){
g_form.setValue('cc_manager', gp.sys_id);
}
}
Now when I open a new item for this, the "Requested By" user from the catalog populates the "Request For" field and the phone number, cost center, and manager from that user's record populate their corresponding fields as well. This is for our Data Security Exception catalog item, so I need them all to tie together so I can send a notification to the manager of the cost center whenever a request is made by someone in the cost center.
thanks again for your help,
Richelle

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 08:54 AM
gs.getUser().getManagerName() will not work in your case as the field is on another table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 10:26 AM
Here's how I got this to work.
1. On the catalog item I changed the Manager field type to Lookup Select Box.
Lookup from table: Cost center [cmn_cost_center]
Lookup value field: Sys_id
Lookup lable field(s): manager
Default value: javascript:getCostCenterSysId(getReqfor(gs.getUserID()));
Reference Qualifier: Active = True
2. I also added the Cost Center (cost_center) Reference field to the catalog item:
Reference: Cost center [cmn_cost_center]
Default Value: javascript:getCostCenterSysId(getReqfor(gs.getUserID()));
Reference Qualifier: Active = True
3. For the Catalog Client Script:
Type: onChange
Variable name: cost_center
Script:
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
var gp = new GlideRecord('cmn_cost_center');
var cc = g_form.getValue('cost_center');
gp.addQuery('sys_id',cc);
gp.query();
if(gp.next()){
g_form.setValue('cc_manager', gp.sys_id);
}
}
Now when I open a new item for this, the "Requested By" user from the catalog populates the "Request For" field and the phone number, cost center, and manager from that user's record populate their corresponding fields as well. This is for our Data Security Exception catalog item, so I need them all to tie together so I can send a notification to the manager of the cost center whenever a request is made by someone in the cost center.
thanks again for your help,
Richelle