Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Dexterity Trigger + Field Change

Posted on by 40

I am trying to write a trigger for when the 'Customer ID' field on SOP Entry changes.  Most of the time, this field value is changed by looking up a 'Document No.'.  I also added a focus trigger to the 'Document No.' field, but that too is not working.  Is it possible that these are not firing because the field never has focus, it is being set by a lookup (which I'm sure runs some procedure)?.  My focus trigger for 'Customer ID' is this:

l_result = Trigger_RegisterFocus(anonymous('Customer Number' of window 'SOP_Entry' of form 'SOP_Entry'), TRIGGER_FOCUS_CHANGE, TRIGGER_AFTER_ORIGINAL, script SOP_CustChanged);
if l_result <> SY_NOERR then
	warning "Failed to register SOP_CustChanged (Customer Number).  Error #:" + str(l_result);
end if;


 

*This post is locked for comments

  • Tim W Profile Picture
    Tim W 2,925 on at
    RE: Dexterity Trigger + Field Change

    Old but not forgotten apparently.

    To log scripts in run time so you can see the scripts called and the parameters passed you need to setup the debug menu to show in the run time client.  You set or add the Dex.ini switch -> ScriptDebugger=TRUE in the dex.ini file.

    Here's a nice blog on the switches available and how this works in general to control program settings.

    dynamicsconfessions.blogspot.com/.../dexini-switches-my-complete-list.html

    Now when you start up the run time client you will see the Debug menu choice above the toolbar.  Navigate to where you want to log the scripts in GP, select Log Scripts, execute the GP logic you are logging, open the menu and uncheck log scripts.  Now you will have a text file of all the dexterity calls executed by the run time.

    Best to undo what you did (especially if you are logging SQL scripts with SQLLogSQLStmt=TRUE) as eventually these processes will create huge text files that might hinder performance.

  • James McCullough Profile Picture
    James McCullough 294 on at
    RE: Dexterity Trigger + Field Change

    Dudes, I know this is a nerco-bump and I'm REALLY REALLY sorry, but I kind of have to know...

    Tim, how in the h-e-double-hockey-sticks do you know what the NAME of the procedure you're hooking into is?  I've tried to find these before, but unless I happen to find one that you or David or Mariano have mentioned I can't find them!  Where do I look?

    Thanks

    -J

  • db707 Profile Picture
    db707 40 on at
    RE: Dexterity Trigger + Field Change

    Thanks Tim!

    The 'Display Existing Record' was exactly what I was looking for.  I was trying to use my original trigger for an existing record, but it was not working.  Using the combination I am able to achieve my desired results.  

    You answer was much appreciated!

  • Verified answer
    Tim W Profile Picture
    Tim W 2,925 on at
    RE: Dexterity Trigger + Field Change

    I did a quick script log on both and the change script for that field does get run on a new document where they are either typing in or selecting a customer via the lookup but not for an existing record.

    .....'SOP_Entry Customer Number_CHG on form SOP_Entry.....

    Your syntax looks correct and so I would think that you should get your code to run on that event but that's essentially only on a new record.

    Here's where I hook into SOP Entry for likely similar logic.

    Results = Trigger_RegisterFocus(anonymous('Display Existing Record' of window SOP_Entry of form SOP_Entry), TRIGGER_FOCUS_CHANGE, TRIGGER_AFTER_ORIGINAL, script <your script here>);

    In <your script here> I first test that 'Display Existing Record' is true (is a new record displayed, if false either the window is empty or the old record is still displayed).

    if 'Display Existing Record' of window SOP_Entry of form SOP_Entry then

    <do some stuff here>

    end if;

    It's convenient in that I might have more than a couple things I do on a newly displayed record and so I can lump it into one script.

    Best

    Tim

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans