
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2016 09:15 AM
Does anyone know how to find a user's live_profile sys_id using the sys_user record? It seems like there must be a relationship between these tables, but it isn't obvious. I can see a table_name field on the live_profile record that is set to sys_user. I assume there is a table somewhere that relates the sys_ids.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2016 09:36 AM
It won't be obvious from the User record side of the equation because the reference exists on the live_profile record.
So a couple options...
1) Search in the live profile table for a document id that matches your user's sys_id. That should yield 1 live profile record you can get the sys_id from
2) Build a custom relationship that matches document id to current user id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 01:37 PM
Robert,
I created the onChange after business rule below to run on insert and update, but it is not making any name changes. Maybe I am going about this wrong because I do not know JavaScript...which may be the whole problem!
(function executeRule(current, previous /*null when async*/) {
// Copy the name from the sys_user table to the live_profile name field
var usr = new GlideRecord("sys_user");
usr.addQuery("sys_id", current.document);
usr.query();
if (usr.next()) {
usr.name = current.name;
usr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 01:41 PM
Lets rewind a bit. Are you finding that your Live Profile names are out of synch with your User names or something?
Why are you building the script in the first place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 02:31 PM
Yes, the live profile name is out of synch with the user name. I was trying to make a business rule that would copy the user name to the live profile name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 07:41 AM
Hi Robert Fedoruk,
I am currently developing a custom Service Portal and I have a requirement in which I need to get on my Service Portal widget's Server Script side, the logged-in user's sys_id in order to execute a query on the Live Message table.
This was my first approach (please see below),
var liveMessages = new GlideRecord("live_message");
liveMessages.addQuery("profile", gs.getUserID());
liveMessages.query();
data.liveMessageCount = liveMessages.getRowCount();
but unfortunatey, the code didn't retrieve the information I need.
After I saw your reply on this discussion I realized that the field "profile" on Live Message table is in fact a reference to the Live Profile table, and that is probably the reason why when I query the Live Message table passing it the user's id it didn't retrieve the count of messages of that user.
Do you have any idea on how I can query this Live Profile table in order to get user's sys_id and then use it to query the "profile" field on Live Message table?
I am missing the right syntax.
Thanks in advance.
Best regards,
Fábio Gonçalves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 03:07 PM
Integrating this into ServicePortal is beyond my experience. However, Live_Profile records have a document reference. In the case of users, it should be the sys_id of user record.
Does that help?