How get current user in RTC plugin
Hello!
We built an RTC extension plug-in which is triggered when an RTC work item is updated. We need to get the info about current connected user who changed the work item (and this action triggered the plug-in). Is any way get information about the use who is currently modifying the work item?
We tried to use this construction:
IWorkItem oldState = (IWorkItem) saveParameter.getOldState();
iContributorHandle = oldState.getModifiedBy();
wi_tmp = (IWorkItem) oldState;
But it seems that "oldState.getModifiedBy();" returns a user who was modifing the work item before the current modification (another word, it was saved in result of the previous call of the plug-in)!
I will appreciate any advices and ideas!
Thank you in advance!
We built an RTC extension plug-in which is triggered when an RTC work item is updated. We need to get the info about current connected user who changed the work item (and this action triggered the plug-in). Is any way get information about the use who is currently modifying the work item?
We tried to use this construction:
IWorkItem oldState = (IWorkItem) saveParameter.getOldState();
iContributorHandle = oldState.getModifiedBy();
wi_tmp = (IWorkItem) oldState;
But it seems that "oldState.getModifiedBy();" returns a user who was modifing the work item before the current modification (another word, it was saved in result of the previous call of the plug-in)!
I will appreciate any advices and ideas!
Thank you in advance!
Accepted answer
The old state will return the user ID that modified the work item to get to that state. The new state should give you the current user that modified the work item to this one.
Also, the operational behavior runs in the context of the user that runs the operation. See https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ and https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ which both access the current user using
Also, the operational behavior runs in the context of the user that runs the operation. See https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ and https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ which both access the current user using
IContributorHandle loggedIn = this.getAuthenticatedContributor();Your extension must extend AbstractService to access this method.