how to get user's uuid by user id in java script for RTC?
Hi Someone who may concern,
We want to update a customized attribute (type:contributor) according to role in team area, say we want to read team area, and fetch the person with role as product owner in the team area back, and update this attribute. However, we can only get user id from team area API as format of the following. but we don't know how to get uuid through user id by any java script function.
https://[local host]:9443/jts/users/xxxx
Since in java script context, we are on ccm server, we can not access jts server directly, how we can get UUID by using user id?
Thanks!
Best Regards,
Jane Zhou
Accepted answer
This JavaScript will do the job for you - you need to supply the Team Area id, and the name of the role as text. If you wanted to use the name of the Team Area instead you could modify the script accordingly.
Note that this script will run asynchronously so that it doesn't affect the performance of your browser, which means that the results may not be available directly in your calling function
dojo.require("jazz.client");
var jazzClient = jazz.client;
var getTeamMembersWithRole = function(team, role) {
if (!team || !role) {
console.log('getTeamMembersWithRole: Error! team = ' + team + ', role = '
+ role);
return null;
}
var xhrArgs = {
url : '/ccm/rpt/repository/foundation?fields=foundation/teamArea[itemId='
+ team
+ ']/roleAssignments/(contributor/itemId|contributorRoles/name)',
headers : {
'Accept' : 'application/xml'
},
handleAs : 'xml'
};
return jazzClient.xhrGet(xhrArgs).then(
function(data) {
var memberIds = data.evaluate(
'foundation/teamArea/roleAssignments[contributorRoles/name/text()="'
+ role + '"]/contributor/itemId', data, null,
XPathResult.ANY_TYPE, null);
var members = [];
var id = memberIds.iterateNext();
while (id !== null) {
members.push(id.textContent);
id = memberIds.iterateNext();
}
return members;
});
};
if (!team || !role) {
console.log('getTeamMembersWithRole: Error! team = ' + team + ', role = '
+ role);
return null;
}
var xhrArgs = {
url : '/ccm/rpt/repository/foundation?fields=foundation/teamArea[itemId='
+ team
+ ']/roleAssignments/(contributor/itemId|contributorRoles/name)',
headers : {
'Accept' : 'application/xml'
},
handleAs : 'xml'
};
return jazzClient.xhrGet(xhrArgs).then(
function(data) {
var memberIds = data.evaluate(
'foundation/teamArea/roleAssignments[contributorRoles/name/text()="'
+ role + '"]/contributor/itemId', data, null,
XPathResult.ANY_TYPE, null);
var members = [];
var id = memberIds.iterateNext();
while (id !== null) {
members.push(id.textContent);
id = memberIds.iterateNext();
}
return members;
});
};
Comments
showing 5 of 8
show 3 more comments
One other answer
This is not supported by the supported and documented JavaScript API for attribute customization. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization for a comprehensive documentation of the supported JavaScript API.
See https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/ for a good overview what is possible and what not.
In the Web UI it would be possible to use RESt APIs to communicate to the server and to get such information.
However, this is not supported and customers have managed to break performance render the UI unusable by doing so. See https://rsjazz.wordpress.com/2019/03/07/registering-custom-resource-intensive-scenarios-to-clm-applications/ for some anecdotal information and suggestions for a minimal performance monitoring.