Topic by ilamukky
Content
Hello,
I would like to use Custom Process to create new records of a custom object (named "version"), linked to Answer object through answerID, when an Answer is updated.
I thought something similar:
Objects: Answer
Actions: Update
1) To create new records on Version (in apply method):
$answer->version->Question = $obj->prev->Question; // to place in version table the old answer fields
$answer->version->save();
$answer->version->Question = $obj->Question; // to create another version record with the new answer fields
$answer->version->save();
2) To retrieve last versionID
$query = sprintf("SELECT CO.answer_version FROM CO.answer_version WHERE answer_id = %s ORDER BY version DESC;", $answer->ID );
$roql_results = RNCPHP\ROQL::QueryObject($query);
if (($roql_result = $roql_results->next()) !== false)
while ($row = $roql_result->next())
$answer->version->version = $row->version;
3) To update Answer custom fields:
$answer->custom_field_name = "To review";
It is the correct way?... Anyone has some examples?
Thanks very much