AL icon indicating copy to clipboard operation
AL copied to clipboard

SubPageLink - field mapping

Open nmahate opened this issue 8 years ago • 8 comments

In C/AL we were able to add a SubPageLink where a Text field could be linked to an integer field as follows:

SubPageLink = "Table No."=CONST(454), "Key Field 1"=FIELD("Entry No.");

Where "Key Field 1" is a text field and "Entry No." is an integer. In AL I get the following error:

image

nmahate avatar Feb 02 '18 15:02 nmahate

Hi @nmahate, could you tells us if there is any reason not to use a matching data type?

defr0std avatar Feb 06 '18 14:02 defr0std

We have a factbox based on RecordID, however in v1 we couldn't add code to the page, so we couldn't pass the RecordID to the factbox We made use of FlowFilters on the source table for the Factbox, by passing the table id and the primary key values using the subpage link. This way we were able extract the values to build the RecordID.

As you can see from the screenshot, the table id is set to the flowfilter field "Table No." and the primary key, "Entry No.", to "Key Field 1". I am aware that now with Page Extensions we're able to add code to call a function on the factbox, to set the RecordID.

nmahate avatar Feb 06 '18 14:02 nmahate

Does it mean then, that using page extensions you can now refactor the solution a bit and have the same data type in the related table?

defr0std avatar Feb 07 '18 10:02 defr0std

It means we can call a function we have on our Factbox to set the RecordID. So they can be linked Added the following code to our Page Extension

    trigger OnAfterGetCurrRecord()
    begin
        CurrPage."My Factbox".Page.SetDocumentRecordID(RecordId);
    end; 

With v1 extensions we couldn't add that line of code. Which made us rethink, and have to use FlowFilters instead.

So, we've found an alternative way to do the linking for our factbox. But wanted to point out that the SubPageLink doesn't work as it did in C/AL

nmahate avatar Feb 07 '18 11:02 nmahate

Thanks for the update. We'll see if this is a common problem.

defr0std avatar Feb 07 '18 11:02 defr0std

@dennisfrostlander We face the same problem when moving to extensions. We have a 'documents' factbox that is added to hundreds of pages using the 'SubpageLink' hack to pass filters and get the recordref / recordid of the master record via the filters in the factbox. In C/AL, we could use dummy text fields to pass any kind of datatype for the primary key field values, in AL we've to create dummy fields for each data type in the primary key :(

It would help us a lot if we could just pass 'RecordID' as value in the subpagelink.

Tried the solution of @nmahate , but this does NOT work in all cases, so no valid workaround for us.


 trigger OnAfterGetCurrRecord()
    begin
        CurrPage."My Factbox".Page.SetDocumentRecordID(RecordId);
    end; 

This code is fine while navigating through existing records. When opening a page and inserting a NEW record, the OnAfterGetCurrRecord trigger is not called, so the RecordID of the linked factboxes is not updated. Only way to force an auto update (after insert of the record) in the linked factboxes is by using the 'Subpagelink'....

fvet avatar Apr 29 '19 18:04 fvet

As a reference (Feel free to upvote) https://experience.dynamics.com/ideas/idea/?ideaid=4bcb9af5-aa6a-e911-b047-0003ff689546

fvet avatar Apr 29 '19 18:04 fvet

I will close this issue. Any future readers should vote on the idea so that it can be considered for a future release.

atoader avatar Feb 02 '21 14:02 atoader