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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to do a Dexterity Trigger when print a GP report.

(0) ShareShare
ReportReport
Posted on by

Hi,

I need to do a function which reads from the temp tables created by a GP report (e.g. RM Statement Report). and then do an action.

here is my code:

---------------------Procedure name: Populate_BAB_RM_Statement_Trx

inout table RM_Statements_TRX_TEMP;
in integer table_operation;

local text localtext;

{BAB_RM_Statement_Trx is a new table hase same format of RM_Statements_TRX_TEMP}

copy from table RM_Statements_TRX_TEMP to table BAB_RM_Statement_Trx; 


save table BAB_RM_Statement_Trx;

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

And then I created a database trigger to fire my code

----------------------Procedure name: Startup

local integer l_result;

l_result = Trigger_RegisterDatabase(anonymous(table RM_Statements_TRX_TEMP), 0, TRIGGER_ON_DB_READ, script RM_Statements_TRX_TEMP);
if l_result<>SY_NOERR then
warning str(SY_NOERR);
warning str(l_result);
warning "Database trigger registration failed.";
end if;

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

Then the procedure code:

---------------------Procedure name: Complete_Message

warning "The Temp table is captured completely";

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

First , 

is this a good idea to read temp tables created by GP reports?

Second,

I need to write a trigger to fire the procedure "Complete_Message". after all operations done on all temp tables used by the report. How i can target that?

Thank you,

Hany

*This post is locked for comments

I have the same question (0)
  • Tim W Profile Picture
    2,925 on at

    I'm not sure if you can do what you describe but maybe.  I do similar in Dex code working with temp tables and there a function that helps me link to GP temp tables from Dexterity.  Caveat, I create the tables then pass them to an existing procedure and act on them after the business logic runs.  I've not tried to link to them as an after process as you describe

    My scenario is a little different.  Business case is  to run the Receivables HATB report but instead of printing it with standard logic, capture into GP temp tables I create, then dump from them to Excel.  Essentially an HATB to Excel and also allows me to write additional fields into the report.

    There is a function in Dexterity that allows me to send and retrieve vales in temp tables: Table_GetOSName()

    I create the temp tables then pass them into my procedure:

    in 'Customer Number' l_customer;
    inout table RM_HATB_Customer_TEMP;
    inout table RM_HATB_Document_TEMP;
    inout table RM_HATB_Applied_TEMP;

    Create variables to hold the Operating System name for the tables:

    local string     RMCustomerTEMP,
                          RMDocumentTEMP,
                          RMAppliedTEMP,

    Use the function to get the actual temp table name (unique every time created)

    {-- Get OS name of temp tables to pass to the stored proc. --}
    RMCustomerTEMP = Table_GetOSName(table RM_HATB_Customer_TEMP);
    RMDocumentTEMP = Table_GetOSName(table RM_HATB_Document_TEMP);
    RMAppliedTEMP = Table_GetOSName(table RM_HATB_Applied_TEMP);

    Then use those names in the call to the procedure.

      call rmHistoricalAgedTrialBalance,
            SQLReturnStatus,
            RMCustomerTEMP,
            RMDocumentTEMP,
            RMAppliedTEMP,
            RMCustListTEMP,
             l_cutoff, {user Input:'Cutoff Date',}
            l_customer,l_customer_id, {Start / End Customer}

            ......

            ......

    Once it runs I can loop through the data in the temp tables (ex. RM_HATB_Document_TEMP) and see and act on the data GP has populated in the tables.  Hardest part was analyzing the rmHistoricalAgedTrialBalance procedure via a script log to figure the stack of values I needed to call it. 

    I'm wondering if you could do the same and put your temp tables into the procedure that prints the statements rather than try and figure it after.  My sense is you need to have to know that table ahead of the run, I don't know if can force the reference after.  I'll give it a try when I get a chance.

    Good Luck

     Tim

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Hi Hany

    It is usually possible to possible to capture a reference to a temp table and to manipulate the contents of the table before a report is printed.

    You will probably need to use the Three Trigger Technique to capture reference from another script that passes the table as a parameter.

    Once you have the reference you can use a second Three Trigger Technique to get the timing of your code to work just before the report prints.

    Articles on Three Trigger Technique

    Part 1: blogs.msdn.microsoft.com/.../using-the-dexterity-three-trigger-technique-part-1

    Part 2: blogs.msdn.microsoft.com/.../using-the-dexterity-three-trigger-technique-part-2

    Please note that there are no triggers on reports.

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans