Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Dex hook location - document write-off

Posted on by 294

Hey Everyone:

I figured there's a lot of people here that have taught me a lot about how to code in Dexterity, and I could use some of that magic right now...  LOL

I have a client who - without going into too much detail - needs to be able to detect when an invoice contains a certain line item at the time of payment/void/reversal/etc.  I've coded a module that will do everything except when the document is reversed using the write-off routine.  Unfortunately, this is an important piece of functionality, and I can't seem to find where the hook should be located.  Using the method that Tim Wappat taught me about how to profile scripts, I've managed to narrow down where I need to hook, except...  I don't know how the system gets and compiles the list of documents that are being written off.

My first instinct is to hook after original onto 'Apply of form rmApply', except that when I noticed this, the form must be getting its list from somewhere because it has the source credit note and the desitnation invoice number.  I suppose (as I write this, I think of it) that I could try and recreate the list of documents that it wants to write off using my own code, but that seems ... inelegant.

Does anyone have a better place to try and insert a script of this nature?  Thoughts?  Experience?

Thanks!

-J

 

Categories:
  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,917 Most Valuable Professional on at
    RE: Dex hook location - document write-off

    Hi James

    I have been doing this a long time and have been working on pushing the limits for decades.

    winthropdc.wordpress.com/.../

    David

  • James McCullough Profile Picture
    James McCullough 294 on at
    RE: Dex hook location - document write-off

    O.M.G.  You are BRILLIANT, dude!  Thank you!  This was EXACTLY what I was after....

    I'm not "blowing smoke"...  But it's astonishing, some of the ideas you have on how to get around things.  Thank you, on behalf of the community, for being willing to share your abundance of knowledge!

  • Verified answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,917 Most Valuable Professional on at
    RE: Dex hook location - document write-off

    Hi James

    You are using Dexterity... of course you can get to the temp table.

    You just need to use the three trigger technique to capture a table reference to the temp table on its first save.

    Trigger on temp table save to store reference to global variable and disable itself using tag.  Disabled on registration.

    Trigger before script to clear reference and enable table trigger to allow capture. Trigger after to perform what you want and then clear reference.

    I did something similar recently using GP Power Tools

    winthropdc.wordpress.com/.../

    Regards

    Davud

  • James McCullough Profile Picture
    James McCullough 294 on at
    RE: Dex hook location - document write-off

    So I've been putting some brain sweat into this one, and I've come to the conclusion that I can find where the TEMP table is populated in Dexterity, but because it's a TEMP table, I can't access it from the module I'm writing.  The routine I'm hooking to with a TRIGGER_AFTER_ORIGINAL is:

    script FillWriteoffDocumentDetailTable of form RM_Writeoff_Documents

    This refers to a TEMP table - RMWriteoffDocDetailTemp - that gets populated by this routine.

    What I can do is replicate the way that the system builds these documents.  The logic is simple enough (in fact I could build that as a stored procedure) on a PRE trigger, then if it's written off on the POST trigger, do my thing.  Is that the best way to handle this, does anyone think?

    -J

  • James McCullough Profile Picture
    James McCullough 294 on at
    RE: Dex hook location - document write-off

    Hi David:

    Thanks for answering.  I've got the sample log attached.  The key lines that I've identified are:

    [line 484] 'ApplyCrdDocToDbDoc of form rmApply', 1, 7, "WCREDT00003453", 9/27/2021, 9/27/2021, "", 1, "INV00276572", 0.00000, 53.00000, 0.00000, 0.00000, 0.00000, 0, table 'RM_Customer_MSTR', table 'RM_Module_SETP', 0
    [line 594] 'Apply of form rmApply', 1, 7, "WCREDT00003453", 1, "INV00276572", 0.00000, 53.00000, 0.00000, 0.00000, 0.00000, -CAD, -CAD, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1-, 4-, 2-, of form rmOpen-, table 'MCRevalDistTEMP', table 'MC_RM_Revaluation'
    [line 739] 'CommitApply of form rmApply', 1, 7, "WCREDT00003453", "I11013206", 9/27/2021, -CAD, 1, "INV00276572", "I11013206", 6/24/2020, "30062020LV", "Sales Entry", "SLSTE00018056", 4, 1, -CAD, 0, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0, 0, 0, 0, 0, 4-, 2-, of form rmOpen-, table 'MCRevalDistTEMP', table 'MC_RM_Revaluation', table 'RM_Customer_MSTR', table 'RM_Customer_MSTR_SUM', table 'MC_RM_Apply_Dist_TEMP', table 'RM_Distribution_WORK', 0
    

    By line 484 the system has the list of documents that it is writing off.  That's the key that I need: what documents is it trying to apply to?  

    In the intervening time I've been thinking about this.  I probably would have to do this in two triggers: one to grab the data before its posted, and the other after it's posted to actually do what it is that I want - because if the process doesn't go through, or stops, I can't update what I need to update.  So that's a piece of what I need.  But I'm still stumped on where to actually find it.

    The specific window that I'm running from (in case it matters) is Dynamics GP --> Tools --> Routines --> Sales --> Write Off Documents:

    pastedimage1633016600754v1.png

    [View:/cfs-file/__key/communityserver-discussions-components-files/32/WTOF-routine.txt

    Thanks for your help!  (Or if anyone else cares to join in?)

    -J

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,917 Most Valuable Professional on at
    RE: Dex hook location - document write-off

    Hi James

    With the script log you captured you said you found the location/script to trigger off.  If you let me know that we could see where it is called from.

    Please post an excerpt of the script log.

    FYI: GP Power Tools makes capturing 5 different logs from GP possible with a single click.

    Regards

    David

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans