LiquidPlanner Classic Forum

Ask a Question
Back to All

Can I add assignment on initial API task creation

Posted on behalf of Vince Farina. Original posting date 2014-10-31.
After reading the READ ME file, it appears that adding assignments without knowing the task ID is possible.

EXCERPT

Creating a treeitem and setting ownership in one request
Since there is no longer, an owner_id attribute on Treeitems, you will need to update the way you set ownership when creating a Treeitem. Instead of setting “owner_id”, you can set the “assignments” to an array of hashes with “person_id” keys. Like this:

(...)

“name”: “Task Name”,

“assignments”: [ { “person_id”: 5} ]

(...)

END EXCERPT

However my php code creates the task, but leaves the task 'unassigned'.

$task = array(
'name' => $lp->dgTaskName,
'parent_id' => $lp->dgTaskFolder, // Specific to Client
'description' => $lp->dgTaskDesc, // Project Type
'promise_by' => $lp->dgTaskDeadline,
'max_effort' => $lp->dgTaskMaxHrs,
'activity_id' => '42587', // constant - client work billable
'custom_field_values' => array('Status' => 'Requested', 'Priority' => $lp->dgTaskPriority),
'package_id' => $lp->dgOwnerPackage ,
'external_reference' => $lp->dgTaskRefID ,
'assignments' => array('person_id' => $lp->dgTaskOwner)
);
// create new task
$result = $lp->create_task($task);

Thanks.