Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
#1 Posted : Wednesday, November 7, 2018 11:55:41 AM(UTC)

Rank: Administration

Groups: Administrators, Registered
Joined: 1/2/2018(UTC)
Posts: 6
United States

Both the Dynamics CRM integration and RapidStart use RecordRef and FieldRef variables to actually apply changes to the underlying tables. In many cases, there are user prompts that are initiated from the table code unless a particular flag is explicitly set to true. This is a real problem because neither of those processes actually *set* the flag to true and the process will just hang with a confirm prompt that is never actually going to be clicked. The problem is even more challenging if you're trying to write your code as a Modern Dev extension, since you can't directly edit the source code of the calling procedure. Even if you are able to add a trigger to an event where you can get direct access to the RecordRef (you can for CRM; you can’t for RapidStart), you can’t convert the RecordRef to a Record by reference, so there’s no way to set the flag directly. There is a way, however, to handle this scenario.

I didn’t want to turn off the prompts *all* the time, so I created a singleton code unit (set the SingleInstance property to true) with a variable on it to track whether or not it should auto-confirm the dialog. I added accessor functions to get and set the variable and set it to true prior to the integration running. Then, I tracked down which field was the actual problem in the table (it was the Buy-from Vendor No. field in the Purchase Header table in my case) and created a modification to that field in a table extension to be able to trigger *before* validate and turn the prompts off.

The code:

tableextension 50100 "Purchase Header Extension" extends "Purchase Header"
        modify("Buy-from Vendor No.")
            trigger OnBeforeValidate();
                ieState: Codeunit "AA IE Import State Management";
                // turn off prompts that will occur when the Buy-from Vendor No. "changes" from nothing to the vendor
                if  ieState.GetImportIsRunning() then

Edited by user Wednesday, November 7, 2018 11:56:21 AM(UTC)  | Reason: Not specified

Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.