
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 06:32 PM
Hi folks,
I'm looking to define the default value for a reference variable on a catalog item based on if the person logged in completing the form matches the assigned_to of the computer asset.
The variable is referencing cmdb_ci_computer table and called 'ref_hostname', I was thinking something like this but I seem to be missing something?
javascipt:if (gs.getUserID = current.assigned_to)ref_hostname = current.name
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 07:03 PM
Hi,
Please try below in Default value:
javascript: var comp = new GlideRecord('cmdb_ci_computer'); comp.get('assigned_to',gs.getUserID());comp.getUniqueValue();
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 06:57 PM
Are you trying the set the default value from cmdb_ci_computer table where assigned to is the looged-in user?
If yes how do you want to set if loggedin user has more than 1 record?
Thanks
Murthy
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 07:03 PM
Hi,
Please try below in Default value:
javascript: var comp = new GlideRecord('cmdb_ci_computer'); comp.get('assigned_to',gs.getUserID());comp.getUniqueValue();
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 08:04 PM
Thanks Anil, worked like a charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 07:33 PM
Hi,
update as this
javascript: var val=''; var rec = new GlideRecord('cmdb_ci_computer'); if(comp.get('assigned_to',gs.getUserID())) val = comp.getUniqueValue(); val;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader