Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

(0) ShareShare
ReportReport
Posted on by

Hi,

I am writing a code using Dexterity and I make a database trigger to run my code when add/update records.

The requirements is to do actions when a change happened to the selected record or when adding a new record.

In the Sales Transaction Entry window, I couldn’t use Changed() Function as this function doesn’t recognize the changes happened in the sub windows (e.g. Sales Distribution Entry). I used the “Changed” field (Changed of window SOP_Entry of form SOP_Entry) which indicates if any change happened to the selected record in the main and all sub windows. So this worked perfect when add or update the “SOP_HDR_WORK” table.

In the Receivables Transaction Entry, there are fields called “Changed” (Changed of window RM_Sales_Entry of form RM_Sales_Entry) and “ChangedFlag” (ChangedFlag of window RM_Sales_Entry of form RM_Sales_Entry). These fields don’t reflected by the changes happened to the selected record and add/update the “RM_Sales_WORK” table, so I couldn’t use them and could not find a way to do the action when the record changed. Again in this window the Changed() Function doesn’t recognize the changes happened in the sub windows (e.g. Sales Transaction Distribution Entry).

Is there any way to recognize the changes if happened in the main and all sub windows for the “Receivables Transaction Entry” window?

Note: The script Handle_Changes (which run when closing the window) recognizes the changes if any happened in the main and all sub windows. I don’t now based on which flag this script works

*This post is locked for comments

  • Suggested answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,006 User Group Leader on at
    RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hany,

    1. What you are referring as sub window is not a sub window, RM Sales distribution is a separate form and have it's own changed flag.

    2. Usually if form have more than one window and we are going to sub window from main window and doing any changes, those changes get save and handled on that window.

    3. It seems you are scripting for some record audit purpose like if any field value changed you will get notify, for this purpose you have to separately register database triggers for respective tables or form triggers for windows and forms, (need to do a little more coding), each form window have different code and something which can work for SOP Entry not necessacrly work for other window.

     

  • RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hi Almas,

    That is a good catch.

    The problem for what I intend to do is that I have to find all sub windows which not reflecting the Changed flag in the main window and write the trigger to force the change flag.

    I am wondering how the GP core script working. the Handle_Changes script which run when closing the form, checks if any change occurred in the main window and all related windows, and it promotes to save the record.

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,006 User Group Leader on at
    RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hany please note you have to register trigger separately like if you want to track chqnges on distribution you have to register trigger for distribution table.

    The piece of code you shared in your last post is working with my dictionary.

    I will go through your details you just shared and will see and let you know.

  • RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hello Almas,

    Appreciate your co-operation.

    unfortunately, the Update database trigger fires when hit save, regardless if there are changes occurred or not. So that doesn't help me as I need to fire my code only when changes occurred.

    Also, the Changed() function doesn't help a lot as it doesn't recognize the changes in some sub windows (e.g. Distribution, Commissions, Tax extension and other windows) for the RM_Sales_Entry form.

    Thank you,

    Hany

  • RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hi David,

    Thank you for your help, but this still doesn't work.

    For RM_Sales_Entry,

    - the changed() function doesn't work with the changes in some sub windows (e.g. Distribution, Commissions, Tax extension and other windows)

    - '(L) Apply Changes' field works only when distribution changed and not with other windows.

    - ChangedFlag field works only if the batch number changed and not with other windows.

    For SOP_Entry,

    I used the Changed field as this field works perfect and returns True if any changes in the main or all sub windows (Don't know why it is not behaving the same in RM_Sales_Entry window).

    I end up with the following in RM_Sales_Entry window:

    I will use the Changed() function. For those windows which not reflecting the changed() function to be True (e.g. Distribution), I will write a trigger when closing the window to force changed flag in the main window if changed flag is True.

    The code will be:

    {This will work with the TRIGGER_FOCUS_POST for the window RM_Sales_Distribution of form RM_Sales_Distribution}

    if isopen(window RM_Sales_Entry of form RM_Sales_Entry) then

    if changed(form RM_Sales_Distribution) then

    force changes form RM_Sales_Entry;

    end if;

    end if;

    Please let me know you recommendations on this piece of code.

    Thank you,

    Hany  

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,006 User Group Leader on at
    RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    To my understanding if you are using database triggers then you don't have to care if changes occurred or not, database trigger take care of it them selves. In fact your database triggers on Add+Update for table RM_Sales_WORK  will only activate when new record gets added or existing is updated, and your script BS_Save_Trx will only be called then, So you don't need to check in your script if changes occurred or not.

    But it seems that in this window after retrieving the existing record window changed flag has not been cleared, and that's why getting issue.

     

    Your code is fine, just try to put window reference inside brackets and it will work. : )

     

    inout table RM_Sales_WORK;

    in integer table_operation;

    if changed(window RM_Sales_Entry of form RM_Sales_Entry)=true then

     

            warning "New changes done";

     

    end if;

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,965 Most Valuable Professional on at
    RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hany

    I checked the source code.

    For RM_Sales_Entry use

    if changed(form RM_Sales_Entry) or ('(L) Apply Changes' <> 0) or ChangedFlag then

    For SOP_Entry use

    if changed(form SOP_Entry) or IsChangedFlags(SOP_ENTRY) then

    Hope this helps

    David

  • RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hello David,

    I tried to use changed() function, but it doesn't serve our needs, as it recognizes only the changes in the main window (e.g. In receivables transactions entry, when selecting an existing document, change the distribution from distribution window and save the document, the changed() function returns False and doesn’t recognize the changes happened) then I found the "changed" field (it returns True when any changes occur in main or sub window) which works perfectly in the sale transaction entry but not in receivables transaction entry.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,965 Most Valuable Professional on at
    RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hi Hany

    Why don't you use changed() on the form rather than individual window.

    David

  • RE: In Dexterity, How to recognize if changes happened to the “Receivables Transaction Entry” window

    Hi Leslie,

    Thank you for your response.

    This is actually what I did. I wrote a database trigger to run a procedure. In the procedure I added the condition to fire just if changes happened. This worked perfect with the “Sales Transaction Entry” window. But in the “Receivable Transaction Entry” window, when saving any existing record, the “Changed” field always has True value, even if no changes done.

    The exact code as following:

    Procedure name: startup

    ----------------------------------------

    local integer l_result;

    l_result = Trigger_RegisterDatabase(anonymous(table RM_Sales_WORK), form RM_Sales_Entry, TRIGGER_ON_DB_ADD, script BS_Save_Trx);

    if l_result<>SY_NOERR then

                   warning str(SY_NOERR);

                   warning str(l_result);

       warning "Database trigger registration failed.";

    end if;

    l_result = Trigger_RegisterDatabase(anonymous(table RM_Sales_WORK), form RM_Sales_Entry, TRIGGER_ON_DB_UPDATE, script BS_Save_Trx);

    if l_result<>SY_NOERR then

                   warning str(SY_NOERR);

                   warning str(l_result);

       warning "Database trigger registration failed.";

    end if;

    -----------------------------------------

    procedure name: BS_Save_Trx

    --------------------------------------------

    inout table RM_Sales_WORK;

    in integer table_operation;

    if Changed of window RM_Sales_Entry of form RM_Sales_Entry then    

    warning "New Changes done";

    end if;

    -------------------------------------------

    Thank you,

    Hany

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans