Workflow Create Record with Date Offset Ignores Selected Date Field

I have a Workflow that runs when a new Quote is created. The workflow creates a new Task with a Due Date set to a custom Datetime field minus 1 week. When the record is created, the selected Datetime field is ignored, and the Due Date is set to Now (UTC time) minus 1 week. Since I am in Eastern US time zone, the actual value is set to Now minus 1 week and 5 hours to be exact.

Is this value calculation in …\modules\AOW_Actions\actions\actionCreateRecord.php?

I believe I have identified the data selection and offset calculation for workflows within modules/AOW_Actions/actions/actionCreateRecord.php around line 173


if($params['value'][$key][0] == 'now'){
    $date = gmdate($dformat);
} else if($params['value'][$key][0] == 'field'){
    $date = $record->fetched_row[$params['field'][$key]];
} else {
    $date = $bean->fetched_row[$params['value'][$key][0]];
}

if($params['value'][$key][1] != 'now'){
    $value = date($dformat, strtotime($date . ' '.$app_list_strings['aow_date_operator'][$params['value'][$key][1]].$params['value'][$key][2].' '.$params['value'][$key][3]));
} else {
    $value = date($dformat, strtotime($date));
}

It appears the math is being done correctly when I select some date plus # days or minus # days; but the date used for calculating is always gmdate. This tells me that the first set of if statements is returning gmdate instead of the selected field date. Does this mean that the $params[β€˜value’][$key][0] is returning the wrong value?

I finally figured it out.

Line 178 of modules/AOW_Actions/actions/actionCreateRecord.php has an error in the assignment statement and should read:


} else {
    $date = $bean->$params['value'][$key][0];
}

For those maintaining the source code files, can someone apply this to a future release?

2 Likes

I would recomend to you that write an Issue in the github page of SuiteCRM. Thanks for the patch.

https://github.com/salesagility/SuiteCRM/issues

Best Regards

Hi

I had exactly this problem with a significant workflow that I had set up, which was presenting the same symptons with date references.
I implement this fix, and Voila! problem solved.

BTW, did this get pushed upstream to GitHub, and patched ?

If not I’d be happy to take care of that

Thanks
Rick

1 Like

Rick,

That would be great if you could push this to GitHub, as I have not.

Thanks,
Scott

All done

Added as additional notes to

https://github.com/salesagility/SuiteCRM/issues/196

That ought to do it

Thanks
Rick