Page 1 of 1

set assigne field

Posted: Wed Jan 23, 2019 5:42 am
by kevin1119
hi all, i'm pretty newbee to scripting in Polarion
as i understand, assignee field is an out of the box Polarion field; not a custom field.
in javascript, i try to set it by calling workitem.setvalue("assignee","my name");
i get this error "List field can never be set"

is that how it's supposed to be?
what data type is assignee?

another option that i can think of is create a new custom list field to work around

Re: set assigne field

Posted: Wed Jan 23, 2019 6:22 am
by micdal
Hi,

try using addAssignee(IUser participant). This "adds a user to the list of assignees." as described in the API documentation.

Regards,
Michael

Re: set assigne field

Posted: Wed Jan 23, 2019 6:43 am
by kevin1119
thanks micdal for suggestion
im trying to copy a user from a custom field of type list ENUM/USER to assignee
i know i have to convert string value to IUser but don't know how to instantiate IUser. can you help?

Re: set assigne field

Posted: Wed Jan 23, 2019 7:07 am
by scharph
Maybe this helps

Code: Select all

#set( $projectsService = $trackerService.getProjectsService())

#foreach( $user in $projectsService.getUsers() )
   >> $user.id - $user.getDescription().getContent() \\
#end


or this

Code: Select all

#set( $assignee = $projectService.getUser($userid))
#set( $dummy = $newWorkitem.addAssignee($assignee))


and maybe this

http://forums.polarion.com/viewtopic.php?f=5&t=97834&p=54443#p54443

best regards

Re: set assigne field

Posted: Wed Jan 23, 2019 8:05 am
by kevin1119
thanks for your help, i got it to work using this approach

var enumOption = orkitem.getCustomField("fieldName");;
workitem.addAssignee(projectService.getUser(enumOption.getId()));