It's all about the answers!

Ask a question

Error while fetching related workitens

benito neto (1667) | asked Dec 10 '14, 1:21 p.m.

Im doing an advisor (@save operation) to check if some spefic type is related to work item.

I want to fetch the relateds items and do something if the type is a task, for example. But when the user try to save the work and dont have permission to read the related items, PermissionDeniedException is throwed.

I would like to know if there is a way to check the work item type when the user dont have the permission.  My code:

IWorkItemHandle wiRelatedHandle = (IWorkItemHandle) related
                                     //This line throws PermissionDeniedException
                                    IWorkItem workItemRelated = (IWorkItem) auditableCommon
                                            .resolveAuditable(wiRelatedHandle, IWorkItem.SMALL_PROFILE,
                                   if (workItemRelated.getWorkItemType().equals(type))

Donald Nong commented Dec 11 '14, 8:35 p.m.

I know of some users who would create a new client interface, log on with a dedicated user and do all the "privileged" stuff. Doing this way will make the code more complicated though.

One answer

permanent link
sam detweiler (12.5k6195201) | answered Dec 11 '14, 11:51 p.m.
No. Unless you do as Donald suggests, there is no way around the security..

just put a try catch around it and catch the exception and ignore it is all you can do.
you should be in a loop processing all the related workitems..
 for(IReference ir: ((ISaveParameter) data). getNewReferences(). getReferences(WorkItemEndPoints.RELATED_WORK_ITEM))
  try {
       // your code
  catch(PermissionDeniedException ex)
       // ignore it

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.