Carefully Place Variables Assignment in Dex


This post is right after a coding correction done in one of my customizations.

There is a form which needs to be opened from both SOP Entry & SOP Inquiry. Based on the source, I had to either lock or unlock certain fields, exactly like how SOP Entry & SOP Inquiry windows work.

I created a GLOBAL field called “SOPSource” and created two Startup trigger scripts, namely SOP_Entry_Open_Addl and SOP_Inquiry_Open_Addl on SOP_Entry and SOP_Inquiry respectively. Inside each script, I wrote a piece of code like below:

open form SOP_Additional_Info;
SOPSource of globals = “ENTRY”; {“INQUIRY” for SOP_Inquiry trigger script}

And once my form is opened, in the Window_PRE event script, I had validated the SOPSource GLOBAL field and made sure that I locked or unlocked the appropriate fields.

Now, can anyone guess what was wrong with the above piece of coding?

Mistake: I wrote the GLOBAL field assignment after “open form” statement.
Reason: The above piece of code first opens the form and then assigns the SOPSource Global field with some value. By the time, it assigns the value, the form is already open and WIN_PRE event is already executed. Due to which, my “SOPSource of globals” will always contain an empty string value.

DUH…

Correct Way of Writing:

SOPSource of globals = “ENTRY”; {“INQUIRY” for SOP_Inquiry trigger script}
open form SOP_Additional_Info;

Those who are new to Dex programming, understand that as soon as a “open form” statement is executed, the form is immediately opened and do not wait for the rest of the calling script’s statements. If there is any dependency in the opened window for other statements in a calling script, we must ensure that these statements are written before we open this window.

VAIDY

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s