How to fetch userid of the modifier of Work Item usind a server side extension?
Hi,
I am working on creating a server-side plugin feature.
I have created a server- side OperationPartcipant.
However, I am not able to get userid for the user who has modified the work item.
Currently I am using below code:
Object data = operation.getOperationData();
saveParameter = (ISaveParameter) data;
IWorkItem newState = (IWorkItem) saveParameter.getNewState();
String modified= newState.getModifiedBy().getItemId().getUuidValue();
Using above code I am getting a UUID value(maybe of user).
Is there a better way to do this?
Any suggestions/ tips would be helpful.
Thanks!
I am working on creating a server-side plugin feature.
I have created a server- side OperationPartcipant.
However, I am not able to get userid for the user who has modified the work item.
Currently I am using below code:
Object data = operation.getOperationData();
saveParameter = (ISaveParameter) data;
IWorkItem newState = (IWorkItem) saveParameter.getNewState();
String modified= newState.getModifiedBy().getItemId().getUuidValue();
Using above code I am getting a UUID value(maybe of user).
Is there a better way to do this?
Any suggestions/ tips would be helpful.
Thanks!
Accepted answer
If you want to do these kind of things it is critical to look at what Java Objects you receive and what you want and also to try to find existing examples.
Start reading here: https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/
See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ it contains almost all the code you need.
The code would look similar to:
IContributorHandle modifierHandle = workItem.getModifiedBy();
IRepositoryItemService repositoryItemService=getService(IRepositoryItemService.class);
IContributor modifier = (IContributor) repositoryItemService.fetchItem(modifierHandle , IRepositoryItemService.COMPLETE);
Start reading here: https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/
See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ it contains almost all the code you need.
The code would look similar to:
IContributorHandle modifierHandle = workItem.getModifiedBy();
IRepositoryItemService repositoryItemService=getService(IRepositoryItemService.class);
IContributor modifier = (IContributor) repositoryItemService.fetchItem(modifierHandle , IRepositoryItemService.COMPLETE);
Comments
One other answer
as often as this comes up, I think this is a failing of the documentation of the system design.
what is needed is a few sentences that describe the data model, using persistent identifiers (handles) in objects, and NOT object references themselves.
and this code needs to go away, and have a method on the base ITeamRepository class that does it
IRepositoryItemService repositoryItemService=getService(IRepositoryItemService.class);
xxx= repositoryItemService.fetchItem(modifierHandle , IRepositoryItemService.COMPLETE);
everyone needs to do this and until you get the model and know the names, its impossible to get your head around it.
what is needed is a few sentences that describe the data model, using persistent identifiers (handles) in objects, and NOT object references themselves.
and this code needs to go away, and have a method on the base ITeamRepository class that does it
IRepositoryItemService repositoryItemService=getService(IRepositoryItemService.class);
xxx= repositoryItemService.fetchItem(modifierHandle , IRepositoryItemService.COMPLETE);
everyone needs to do this and until you get the model and know the names, its impossible to get your head around it.