javascript: gs.getUser().getRecord().getValue('location') is not Working in Record Producer Kingston
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2018 02:36 AM
Hello There,
I have created a Location reference field with table as cmn_location and in the default value i have given as javascript: gs.getUser().getRecord().getValue('location') [have even tried with javascript: gs.getUser().getLocation() but no luck] which is not working in my Work instance which runs on Kingston. When i try same on my personal Kingston instance it is working as expected. Much appreciated if any suggestions on how to work around on this..
Thanks in advance!
- Labels:
-
Service Catalog
- 12,777 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 12:28 AM
Hi,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 10:43 AM
The solution is to create a script include and query it using the gs.getUserDisplayName() from sys_user;
var ServiceCatalogAjax = Class.create();
ServiceCatalogAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
returnUserLocation: function() {
var user=new GlideRecord('sys_user');
user.addQuery('name', gs.getUserDisplayName() );
user.query();
user.next();
return user.location;
},
type: 'ServiceCatalogAjax'
});
javascript:yourscopename.ServiceCatalogAjax().returnUserLocation();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 10:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2019 10:57 AM
As the Location field is on the user profile you should just be able to use "myUserObject.getLocation() -- returns the current user's location"
Which should only require your script to be:
javascript:gs.getUser().getLocation();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 05:17 AM
PFB
javascript:gs.getUser().getRecord().getDisplayValue("location");