Problems with using g_user on a service portal widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 03:19 AM
Hi,
Does anyone know a way for me to get a field value off a user form in angular?
I have tried using a script action to put the field into the user session data and then used 'g_user.getClientData('field name');' to get the stored field data but this seems to break the widget, I have had a look around the community and noticed that a few other developers have had issues with g_user.
I have also tried using glide to dot walk to the user record and find the field but this does not work either.
Cheers,
Tom
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 04:11 AM
Can you post your codes here pls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 04:29 AM
So the widget is the standard out the box connect support widget. I have created a 'session.established' Script Action to pass the field 'vip' into the user session data.
I have cloned the connect support widget and added/amended the sections (in Bold under the 'Widget Client Script:' heading below which form part of the client script for the widget.
The intention of the code is to check whether or not a user is a VIP and depending on the outcome direct them to the appropriate chat support queue.
Script action:
var user = new GlideRecord('sys_user');
user.addQuery('sys_id' , gs.getUserID());
user.query();
if (user.next()){
vip = user.vip;
}
gs.getSession().putClientData('vip', vip);
Widget Client Script:
function connectSupportCtrl ($scope, $http, $window) {
var url = '/api/now/connect/support/queues';
if ($scope.widget_parameters.queue_name)
url += '?queue_name=' + $scope.widget_parameters.queue_name;
if ($scope.widget_parameters.queue_i
url += '/' + $scope.widget_parameters.queue_id;
$http.get(url).then(function (response) {
if (response.data.result && response.data.result.length)
angular.extend($scope.data, response.data.result[0]);
else
angular.extend($scope.data, response.data.result);
});
$scope.open = function () {
var clientVIP = g_user.getClientData('vip');//Grabs the VIP value out of session data
if (clientVIP == 'false'){
$window.open('/$chat_support.do?queueID=' + '611bfc964f807e008488e1128110c76d', '_blank', 'location=no,toolbar=no,menubar=no,scrollbars=yes,width=760,height=600'); //Take the user to the standard chat queue page
}
if(clientVIP == 'true'){
$window.open('/$chat_support.do?queueID=' + 'c54f0abf0a0a0b452db84664f409c79c', '_blank', 'location=no,toolbar=no,menubar=no,scrollbars=yes,width=760,height=600'); //Take the user to the VIP chat queue page
}
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2017 01:42 PM
Hi Thomas,
Thanks for sharing.
We're trying to enable that Connect Support chat on the portal and get country information from the user data and based on that, assign the chat to the agent that speaks the same language as the user.
Was wondering where did you put that 'session.established' script action.
Thanks in advance,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 07:36 AM
$scope.page.g_user should work