
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2018 09:14 PM
I have a requirement for a couple of fields to be populated with the appropriate information once a customer adds the name of the 'owner' of a dashboard - that persons email and department needs to then be added to the appropriate fields.
I have checked a number of forum posts similar, tried most of them and still can't get it to work, so here I am asking directly.
So based on the Owner name being added (which shows as the first name and surname - eg: Joe Bloggs) - note: it is almost certainly not going to be the name of the user entering the details.
owner_section would map to the 'Department' field
owner_email would map to the 'email' field
I believe all are available through sys_user
Also as a side question - is it possible to allow free text in a reference field if someone needs to enter something that is not available to select?
If someone could let me know how to do this I'd certainly be grateful.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2018 10:41 PM
Can you make that variable as reference and refer to cmn_department table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2018 10:41 PM
Can you make that variable as reference and refer to cmn_department table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2018 08:39 PM
I thought it would be good to add the entire solution so anyone else looking for something similar might understand it easier.
Variable Names | Variable Field Types | ServiceNow Fields |
owner_name | Reference (sys_user) | |
owner_email | single text line | |
owner_section | Reference (cmn_department) | department |
Catalog Client Script:
Applies to | Catalog Item | Application | Global | |
Active | True | Type | onChange | |
UI Type | ALL | Catalog item | (choose the item you want this to work on) | |
Variable name | owner_name (name of the variable you are updating) |
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ownerdetails = g_form.getReference('owner_name', doAlert);
}
function doAlert(ownerdetails) {
g_form.setValue('owner_email',ownerdetails.email);
g_form.setValue('owner_section',ownerdetails.department);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2018 10:55 PM
You'll not get department name by getting reference from sys_user table. You'll only get the sys_id of department as that's what is actually stored at user level. Dot walking works in business rules but not at client script level. So make owner_section as reference variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2018 11:57 PM
Any updates Moedeb??
If you find the solution please mark my answer as correct and close the thread...