[SOLVED] Capture old variables on Before update

Hello,

I would like on a form to capture old value and new value of a field record.
The field is {race}

OnBeforeUpdate, i put these lines:
$old_race = {race};
sc_set_global($old_race);

OnAfterUpdate, i send by mail this line:
$mail_message = 'Type d’articles ‘.{PRODUCTION}.’ Ancienne race ‘.{old_race}.’ Nouvelle race: '.{race}; // Message body

But it’s return always the new value of {race}:
Type d’articles Articles muscles congel?s avec maturation Sta lAncienne race MAINE ANJOU Nouvelle race: MAINE ANJOU

I was waiting for:
Type d’articles Articles muscles congel?s avec maturation Sta lAncienne race CHAROLAIS Nouvelle race: MAINE ANJOU

Could you help me?
Best regards,
Olivier

In the onbeforeupdate the new value is already there in the field which you refer to. To retrieve the old data you need to use the onload event. This event is triggered whenever a new record is selected. If you save your data into a global here it will be available in the onbefore- and onafterupdate.

Form … onRecord …?

No, you’re right, I meant the onload.

Hello,

Thanks for help.
I tri do save the tghe old value in a data, but i can’t exploit it then:
Onload, i put these lines:
$old_race = {race};
sc_set_global($old_race);

OnAfterUpdate, i send by mail this line:
$mail_message = 'Type d’articles ‘.{PRODUCTION}.’ Ancienne race ‘.{old_race}.’ Nouvelle race: '.{race}; // Message body

But i have this message when i validate:

Erreur

Undefined variable: old_race

What’s means?

I try to use old_race with [] in OnAfterUpdate, but same message.

Best regards,
Olivier

bUT I HAVE THIS MESSAGE/

sc_set_global($old_race) => [old_race] not {old_race} …

Btw, in the documentation for sc_set_global():

NOTE: This macro will be discontinued soon. You should use the method of creating global variables ??using brackets. Ex: [var_glo_user] = “test”;

Hello,
It’s OK now, I use correctly variables.
Thanks for you help!

Olivier

Hello,
I’ve a little problem:
my code is the following:
onload:
$old_race = {race};
sc_set_global($old_race);

OnAfterUpdate:
$mail_message = 'Type d’articles ‘.{PRODUCTION}.’ Ancienne race ‘.[old_race].’ Nouvelle race: '.{race}; // Message body

When I close developpement envorinnement, on re-open, and lauch the application, i have the message as the global variable is not existing.

I must suppress .[old_race] in OnAfterIpdate, compile, lauch, and put it again!!!
Then it’s OK!!

Do you have any idea??
Best regards,
Olivier