Setting Restricted Access programmatically
Hi All,
Am using Restricted Access feature provided in RTC v3.0 for controlling view access for couple of work items for list of users. I understand that we can have it enabled on web client by including "Restricted Access" attribute in our editor presentation. Now I have a scenario wherein, I would need to create work items programmatically. I would want these newly created ones also to be set for access controlling by default. Can I set this attribute "Restricted Access" also in my program to achieve this?? Any pointers in this direction would greatly help. Thanks
Thanks & regards,
Mohan
Am using Restricted Access feature provided in RTC v3.0 for controlling view access for couple of work items for list of users. I understand that we can have it enabled on web client by including "Restricted Access" attribute in our editor presentation. Now I have a scenario wherein, I would need to create work items programmatically. I would want these newly created ones also to be set for access controlling by default. Can I set this attribute "Restricted Access" also in my program to achieve this?? Any pointers in this direction would greatly help. Thanks
Thanks & regards,
Mohan
One answer
Hello Mohan,
yes you can set the Restricted Access att of a WorkItem programmatically. You basically need to get the UUID from the Project Area you want to set the value for and set the contextId attribute. Here I add you some snippets to try to help out:
Hope this eskeleton snippets help.
Regads,
Jorge
yes you can set the Restricted Access att of a WorkItem programmatically. You basically need to get the UUID from the Project Area you want to set the value for and set the contextId attribute. Here I add you some snippets to try to help out:
// Assume pArea1 is WI's Project Area
// and PArea2 is to what you want to set security context
// Both assignable to IProjectArea
IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
// Retrieve Restricted Attribute
IAttribute restrictedAtt = service.findAttribute(pArea1, "contextId", monitor);
// I assume you already have your WorkItem WorkingCopy
IWorkItem workItem = <workingCopy>.getWorkItem();
// From a Project Area, you have to get the UUID
UUID secContext = pArea2.getContextId();
workItem.setValue(restrictedAtt, secContext);
...
Hope this eskeleton snippets help.
Regads,
Jorge