Set author as assignee

Description
DCwom
Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Set author as assignee

Postby DCwom » Fri Dec 26, 2014 8:24 pm

I want to set the assignee of a work Item to the author (during a transition to a resolved state). I am using the scripting extension and have success fully managed to get the author's id in my script but once again I am baffled by the Polarion API when I try to set the assignee. I've tried numerous incarnations of the setAssignee method of workItem but nothing will compile. I'm probably hung up on the User portion of the Assignee method but I can't figure it out. Any odea's what I'm doing wrong?
Dennis

Code: Select all

var workItem = workflowContext.getWorkItem();
var author = workItem.getAuthor().getId();
workItem.setAssignee(author);

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Set author as assignee

Postby martins » Fri Jan 02, 2015 7:43 am

Hello Dennis,

because Assignee is a multi value field there is no simple "setAssignee" method in the IWorkItem interface.

Therefore you have to use method "addAssignee" to add an IUser object (not just the ID!) to the workitem.
In your example

Code: Select all

workItem.addAssignee(workItem.getAuthor());
should work.

Kind regards

Martin


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: franciscokq16 and 16 guests