Location of a javascript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2012 05:17 AM
Hi,
Please can you tell me the location in Service-Now of the java scripts set up in the gauge "My Work"
There are 2 in the gauge "javascript:gs.user_id()" and "javascript:getMyGroups()".
I wish to creat a new one and just want to see the format.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2012 05:36 AM
getMyGroups() is a function in Global Business rule, and gs.getUserID() will return the SYSID of the user is currently logged in.
You can only see getMyGroups, you cannot see getUserID() function. Its a method of Glide Object. We are using javascript: to call these functions.
You can define your own function getMyCoolGroups() if you define it in a Global Business rule and return a comma seperated sys_ids.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2014 11:44 PM
Hello,
sorry to bother you, but why I dont have luck to get back my groups as display Value ?
I always get sys_id. How do I do get AG name's ?
I tried this through script background like below code, but I get nothing
Petr
var de = gs.getUser().getMyGroups();
gs.print(de);
Result is *** Script: [3c946b4c09d920000b30bdedc6e5e47b, 5496a2f609e924000b30bdedc6e5e43d, b8946b4c09d920000b30bdedc6e5e478]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2014 12:47 AM
Hi Pastupe,
Please try the below code
Script:
var ourUser = gs.getUser();
var ourGroups = gs.getUser().getMyGroups();
var grpDisplay = '';
for ( var i=0; i < ourGroups.size(); i=i+1)
{
var group = new GlideRecord('sys_user_group');
group.get(ourGroups.get(i));
grpDisplay = grpDisplay + group.name + '\r\n';
gs.addInfoMessage(grpDisplay);
}
Please let me know if you have any questions.
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2014 03:33 AM
Thanks a lot, yes it work now with your code.
Could I have some comment to this ?
Below are comments in the code, I would like to learn from this, could you please control my comments if Im right or not ?
Thank you
Petr
var ourGroups = gs.getUser().getMyGroups(); // this get my groups where I do belong
var grpDisplay = ''; // what is purpose of this ?
for ( var i=0; i < ourGroups.size(); i=i+1) // this is an array where all found records will be taken ?
{
var group = new GlideRecord('sys_user_group'); // database query ?
group.get(ourGroups.get(i)); // why this cannot be as common query like group.addQuery..... ?
grpDisplay = grpDisplay + group.name + '\r\n'; // here we translate result value to display value ?
gs.addInfoMessage(grpDisplay); // this print me results as system message
}