Page 1 of 1

Enum of a Custom Field

Posted: Tue Aug 03, 2010 2:58 pm
by genesis
Hello everybody,

Actually I am working on a Servlet and I am trying to get all possible Values for a Custom Field.

I guess it should work with "trackerService.getDataService().getEnumerationForEnumId(IEnumType, IContextId)".

But how do I get the IEnumType and the IContextId for the Custom Field in a certain project or an certain WorkItem Type?

Thanks a lot for any advise!

Re: Enum of a Custom Field

Posted: Fri Aug 06, 2010 9:22 am
by ChernikovaEkaterina
Hello,

contextId can be find by : project.getContextId()
IEnumType is ICustomField.getType(), this ICustomField find the same:
IDataService.getCustomFieldsService().getCustomField("myfield", IWorkItem.PROTO, contextId, null) for not type-specific field
IDataService.getCustomFieldsService().getCustomField("myfield", IWorkItem.PROTO, contextId, "mytype") for "mytype"-specific field

Best Regards,
Ekaterina Chernikova
Polarion Support

Re: Enum of a Custom Field

Posted: Thu Aug 12, 2010 12:08 pm
by genesis
Thank you very much, exactly what I`m looking for... ;)

Re: Enum of a Custom Field

Posted: Mon Feb 27, 2012 12:25 pm
by lgrossmann
Hello,

I am trying to get the same in a wiki-content. Can you tell me how I should call this function:

$trackerService.dataService.getEnumerationForEnumId(IEnumType, IContextId)

I have tried:
#set($repoContextId = $projectService.rootProjectGroup.containedGroups.get(0).contextId)
$trackerService.dataService.getCustomFieldsService().getCustomField("myfield", "Worktiem", $repoContextId, null)

But it isn't working...

Thank you!!

Re: Enum of a Custom Field

Posted: Tue Feb 28, 2012 8:55 am
by vinicius.zavam
getting everything;

Code: Select all

 #set ($ds = $trackerService.getDataService())
 #set ($contextID = $trackerService.getTrackerProject(${MYPROJECT_POBJ}).contextId)
 #set ($nwi = $trackerService.getTrackerProject(${MYPROJECT_POBJ}).createWorkItem("${MYWORKITEMTYPE_ID}"))
 #set ($enumtype = $polarionTool.typeFactory.getEnumType("${MYCUSTOMENUM_ID}"))
 #set ($myenum = $ds.getEnumerationForEnumId(${enumtype}, ${contextID}))


quering for all possible values;

Code: Select all

#set ($myoptions = $myenum.getAllOptions())


setting data;

Code: Select all

 #set ($myenum = $myenum.wrapOption("${MYCUSTOMENUM_ID_VALUE}"))
 $nwi.setValue(${MYCUSTOMFIELD_ID}, ${myenum})