Jump to content


Photo

Custom on-Save Workflow

workflow

  • Please log in to reply
1 reply to this topic

#1 martin.zeug

martin.zeug

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 28 July 2015 - 03:09 PM

Hi,

 

I want to add a custom on-save Workflow action to update a custom field with a calculated value.

Everything works fine, but how to integrate the "calculated value" is it possible to add an third programmed action after "as, as empty" like for example a SQL query or a PHP function? When it is possible to call a function to generate the calculated value where to put it?

 

Greetings,

 

Martin



#2 martin.zeug

martin.zeug

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 29 July 2015 - 02:40 PM

Up to now I "hacked" zurmo a little bit and added my calculation to models/Account.php

The field is calculated and updated, every time an activity is created. It would be possible to check if the custom field is empty.. but not neccessary in this case. 

 public function setLatestActivityDateTime($dateTime)
 {
    assert('is_string($dateTime)');
    AuditUtil::saveOriginalAttributeValue($this, 'latestActivityDateTime', $dateTime);
    $this->unrestrictedSet('latestActivityDateTime', $dateTime);

// calculate / update custom field
     $accountId = 5000+$this->id;
     $accountNr = "CUSTOMER-{$accountId}";
     AuditUtil::saveOriginalAttributeValue($this, 'account_nrCstm', $accountNr);
     $this->unrestrictedSet('account_nrCstm', $accountNr);
    }







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users