It's all about the answers!

Ask a question

Setting Restricted Access programmatically

Mohan K M (1111511) | asked Mar 04 '11, 2:42 a.m.
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,

One answer

permanent link
Jorge Diaz (8664434) | answered Aug 04 '11, 3:40 a.m.
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:

// 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.




Neal McKegney commented Jul 04 '13, 7:17 a.m. | edited Jul 04 '13, 1:55 p.m.

I'm using 4.0.3, and I'd like to programatically set Restricted Access to an Access Group.  Is this possible?  I haven't figured out how to return the UUID for the Access Group. 

Ralph Schoon commented Jul 04 '13, 7:40 a.m.

The code above would work for 4.0.3 as well.

Neal McKegney commented Jul 04 '13, 1:50 p.m.

That code is getting the UUID for the Project Area though... I'm trying to get the UUID for an Access Group.  Or am I missing something?

Ralph Schoon commented Jul 05 '13, 1:23 a.m.

See and look into how I get the SecurityContextProvider that actually uses them. Look into the code.

I think it is


So you get them from an AuditableCommon service or client library.

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.