bea
Active Member
Hi,
I have two different scripts running on one form (1).
1st script: insert a new record with onBeforeStore on table 1
2nd script: inserts records with onAfterProcess on table 2 (depends on values on table 1)
Require Once set both to YES
The problem now:
My first script updates the control field, if a record is already generated ('fab_cp1_line_tour___record') from 1 to 2 (new record generated)
My 2nd script is watching ('fab_cp1_line_tour___record') and runs if value is 1. When this script runs, the value is already 2, because of 1st script and nothing happens
To solve this, I've tried to combine insert script and updateFormData in 2nd script and stop updating 'record' from 1st script >> (Wiki). It doesn' work.
Part of 2nd script:
Hopefully I'm clear enough...
Many thanks
Bianka
I have two different scripts running on one form (1).
1st script: insert a new record with onBeforeStore on table 1
2nd script: inserts records with onAfterProcess on table 2 (depends on values on table 1)
Require Once set both to YES
The problem now:
My first script updates the control field, if a record is already generated ('fab_cp1_line_tour___record') from 1 to 2 (new record generated)
My 2nd script is watching ('fab_cp1_line_tour___record') and runs if value is 1. When this script runs, the value is already 2, because of 1st script and nothing happens
To solve this, I've tried to combine insert script and updateFormData in 2nd script and stop updating 'record' from 1st script >> (Wiki). It doesn' work.
Part of 2nd script:
PHP:
...
if($record[0] == 1 && $status[0] == 2 && $order == 3 && ($security_checks_col == '3' || $security_status[0] == 3)) {
$query=$mydb->getQuery(true);
$query->insert('fab_deviation_standard')
->set('parent_id = '.$mydb->quote($parent_id))
->set('machine = '.$mydb->quote($machine))
->set('pw = '.$mydb->quote($period))
->set('date_time = '.$mydb->quote($date))
->set('shift = '.$mydb->quote($shift))
->set('color = '.$mydb->quote($color))
->set('status_icon = '.$mydb->quote($security_status))
->set('target = '.$mydb->quote('100%'))
->set('indicator = '.$mydb->quote('Sicherheit'))
->set('deviation = '.$mydb->quote('Checks: '.$security_checks_pc.' --- '.'Beinaheunfälle: '.$security_nearmiss.' --- '.'Vorfälle: '.$security_incidents))
->set('comment = '.$mydb->quote($security_comment));
$mydb->setQuery($query);
$mydb->execute();
$id=$mydb->insertid();
$formModel->updateFormData('fab_cp1_line_tour___record', '2');
}
...
Hopefully I'm clear enough...
Many thanks
Bianka