web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

How to make focus trigger script run only when alternate window is marked.

Almas Mahfooz Profile Picture Almas Mahfooz 11,009 User Group Leader

How to make focus trigger script run only when alternate window is marked.

It's something we always need, to only run our code when alternate dynamics GP window is marked. When Dynamics GP gets its focus triggers registered, it doesn’t do it on the bases of product.

The Trigger_RegisterFocus() function registers a focus trigger for use with the run-time engine. Focus triggers are activated by “focus” events in an application, such as a window opening or closing, or the focus moving from one field to the next.Focus triggers require that you specify the object that activates the trigger (such as a window, form or field), the focus event for that object (such as a pre, change or post event), and the procedure you want to run in response to the trigger.

When Dynamics GP login, it register triggers from all products through a "Startup" procedure. For multiple applications, "Startup" procedures run in the order in which the applications are listed in the launch file. Let's say we have a custom application dictionary "AOGPP.DIC", having focus trigger on "sop type" change.

Startup

local integer l_result;

l_result =  Trigger_RegisterFocus(anonymous('SOP Type' of window SOP_Entry of form SOP_Entry),

TRIGGER_FOCUS_CHANGE,TRIGGER_AFTER_ORIGINAL, script sopChange);

if l_result SY_NOERR then

warning " trigger registration failed.";

end if;

1

We want to run our script when our alternate sales transaction window is marked for the user.We can do it by using alternate modified tables records, another way we can do it by using exception handling script.

2

We will create a local field '(L) runme' on sales transaction window and put our code there (whatever needs to be done of trigger script) and on trigger script we will execute that code by using run script method.

Trigger Script: sopChange

local integer product_ID;

product_ID = Runtime_GetCurrentProductID();

if product_ID=9999 then

try

run script '(L) runme' of window SOP_Entry of form SOP_Entry;

catch [EXCEPTION_CLASS_SCRIPT_ADDRESSING]

{do nothing }

else

{do nothing}

end try;

end if;

 

On local field '(L) runme', we will write our code. For testing purpose; just put a warning there

warning "I hate hello world Programs.";

Now code will run only when alternate window is marked. :)

That's it. :)

http://wp.me/p15M7D-T

 

Comments

*This post is locked for comments