[Vtigercrm-developers] Anyone written a VTUpdateFieldsTask programatically?

Alan Lord (News) alanslists at gmail.com
Tue Apr 9 20:25:00 UTC 2013


On 09/04/13 15:33, Alan Lord wrote:
> Hi,
>
> just wondering if anyone has already done this?

Replying to myself and for the record I've almost worked it out.

> // Task 3 - Update the agent's commission value
> $Acctask3 = $taskManager->createTask('VTUpdateFieldsTask', $AccWF->id);
> $Acctask3->active = true;
> $Acctask3->field_value_mapping = '[{"fieldname":"agentcomm", "valuetype":"expression","value":"commission * (agentcommpc/100)"}]';
> $Acctask3->summary = "Update Agent's Commission";
> $taskManager->saveTask($Acctask3);

This works :-D

But I haven't yet figured out a way of adding more than one field per 
task entry.

In the database if I create a task with say two or three fields, each 
field mapping is inside the "[{map1},{map2},{map3}]" - I tried doing 
that but is didn't seem to work at all, so right now I am just creating 
a separate task for each field.

It's not a huge deal but it would be nice to get to the bottom of this.

Cheers

Al


-- 
Libertus Solutions
http://www.libertus.co.uk



More information about the vtigercrm-developers mailing list