Skip to main content
Dynamics 365 Community / Forums / Finance forum / ERROR deep link code (...
Answered

ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()

editSubscribe (0) ShareShare
ReportReport
Posted on by 30
Hello,
 
I want to populate a deep link to a certain record (in my example SalesTable) via a data entity. Therefore I created an unmapped field (/deepLink/) on the entity and tried to fill it in the /postLoad()/ method:
 
This is a display method on a custom table creating the deep link URL, which returns the correct value (tested via Form):
public display str getDeepLinkSalesTable()    {        str deepLink;        // gets the generator instance        var generator     = new Microsoft.Dynamics.AX.Framework.Utilities.UrlHelper.UrlGenerator();        var currentHost   = new System.Uri(UrlUtility::getUrl());        generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);        generator.Company = curext();        generator.MenuItemName = menuItemDisplayStr(SalesTable);        generator.Partition = getCurrentPartition();        // repeat this segment for each datasource to filter        var requestQueryParameterCollection = generator.RequestQueryParameterCollection;        requestQueryParameterCollection.AddRequestQueryParameter(formDataSourceStr(SalesTable, SalesTable), fieldStr(SalesTable, SalesId), this.SalesId);        System.Uri fullURI = generator.GenerateFullUrl();        // to get the encoded URI, use the following code        if (fullURI.AbsoluteUri != //)            deepLink = fullURI.AbsoluteUri;        return deepLink;    }
 
It is called in the postLoad of a data entity:
public void postLoad()    {        super();        this.DeepLinkSalesTable = CustomTable::find(this.SalesId).getDeepLinkSalesTable();    }
 
The code compiles well but when running an ODATA GET against the entity I get an CLR error:
////
 
Any help would be appreciated.
 
Thanks in advance
Sebastian