Set Enum of new created Workitem

Description
scharph
Posts: 3
Joined: Wed Jul 04, 2018 9:19 am

Set Enum of new created Workitem

Postby scharph » Wed Jul 04, 2018 12:53 pm

I want to create a new Workitem and set the value of a custom field("interface").

The custom field has type enum and there a multiple values possible!
The enum is custom created in a [workitem]-[title]-enum.xml in the same project

My Problem:
i have the id("team_6") of the enum which should be added, but i have no idea how to add them to the custom field


i tried this:

Code: Select all

  $newWorkitem.setCustomField("interface", $ENUM.wrapOption("team_6"))


Wrapped Exception: Invocation of method 'setCustomField' in class com.polarion.alm.tracker.internal.model.WorkItem threw exception class java.lang.ClassCastException : com.polarion.platform.persistence.spi.DelegatingOption cannot be cast to com.polarion.platform.persistence.spi.CustomTypedList

also this:

Code: Select all

$newWorkitem.setEnumerationValue("interface", "team_6"))


same problem:

Wrapped Exception: Invocation of method 'setEnumerationValue' in class com.polarion.alm.tracker.internal.model.WorkItem threw exception class java.lang.ClassCastException : com.polarion.platform.persistence.spi.DelegatingOption cannot be cast to com.polarion.platform.persistence.spi.CustomTypedList

For the severity enum this is working but not with my custom enum.
Where do i get this CustomTypedList??

This is my Code:

Code: Select all

$transactionService.beginTx()

#set( $newWorkitem = $trackerProject.createWorkItem("agenda") )
$newWorkitem.setTitle("My Workitem Title")
$newWorkitem.setDueDate($objectFactory.newDateOnly($dateTool.toDate("yyyy-MM-dd", "2018-02-20")))

$newWorkitem.setEnumerationValue("severity", "A")
$newWorkitem.setCustomField("catchWords", "Schlagwort")

$newWorkitem.setCustomField("interface", ???????)

##$ENUM.wrapOption("team_6") $ENUM.wrapOption("team_6").class

$newWorkitem.save()

##$transactionService.commitTx()
#info("Done.")


Thank you
Best regards Philipp
Last edited by scharph on Mon Oct 01, 2018 6:57 am, edited 1 time in total.

scharph
Posts: 3
Joined: Wed Jul 04, 2018 9:19 am

Re: Set Enum in new created Workitem

Postby scharph » Wed Aug 22, 2018 7:40 am

Found the solution by myself

:idea:

This is a multiselect field.
I catch the empty field of the new workitem, and add the entries.
Then set it with setValue

Code: Select all


#set( $customTypedList = $newWorkitem.getCustomField("interface") )
#set( $dummy = $customTypedList.add(0,$interfaceEnum.wrapOption($team.id)) )
$newWorkitem.setValue("interface", $customTypedList)



easy :mrgreen:


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 11 guests