Confused about Attributes

I need a variable that has “Application” level scope. I need to be able to set it and get it in any of the Form’s Events (single record form). I found the Programming/Attributes feature and I was able to add an attribute called “ChangeSequence” (Note that I did not use a v nor $ in front). Now my problem is, I need to set and get the value of this attribute in various Events, and I’m having no success. Can you tell me the proper way to do this?

I need to SET the variable when a record is first retrieved/displayed or when the display is refreshed from the DB.

Should I use OnLoad or OnNavigate or OnRefresh? What is the syntax I should use within these events?

$ChangeSequence = {CHG_SEQ}; Is this the correct way to set the Attribute ChangeSequence from a field called CHG_SEQ?

Then I need to GET the value in the ChangeSequence Attribute, that was SET in one of the events above, from within the OnBeforeUpdate event.

What is the syntax I should use within this event ? Example: $error_test = {chg_seq_from_db} != $ChangeSequence;

Note: This always resolves to True (which is wrong), because SCv6 x16 thinks $ChangeSequence is a local var only, and is empty. It does not seem to contain the value that was set in the OnLoad event.

Then, I need to fetch the latest CHG_SEQ from the DB record and set the ChangeSequence again. But again, this is not working. Here is my code.
(I get a “Variable not defined” error message)

$check_sql = “SELECT CHG_SEQ FROM JET_CLN WHERE OBJ_GUID = '” . {OBJ_GUID} . “’”;
sc_lookup(rs, $check_sql);

if (isset({rs[0][0]})) // Row found
{
$ChangeSequence = {rs[0][0]};
}
else // No row found
{
$ChangeSequence = ‘’;
}

$javascript_title = ‘After Update - $ChangeSequence’;
$javascript_message = $ChangeSequence;
sc_ajax_message($javascript_message, $javascript_title);

What is the correct syntax to use in this event to SET the ChangeSequence attribute?

I’ve tried various combinations of [ , $ , v, etc. with no success.

Re: Confused about Attributes

I got my answer in the NetMake KnowledgeBase.

http://www.netmake.com.br/knowledge/article-279.html

All is working ok now.