Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / ERROR deep link code (...
Finance forum
Answered

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

(0) ShareShare
ReportReport
Posted on by 62
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
  • Verified answer
    Basti Aurand Profile Picture
    Basti Aurand 62 on at
    ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()
    Unfortunatly, I didn't figured out to get my debugger working. Nevertheless the solution was to use "EnvironmentFactory" instead of "UrlUtility" to get the correct environment URL:
     
    IApplicationEnvironment env = EnvironmentFactory::GetApplicationEnvironment();
    str currentUrl = env.Infrastructure.HostUrl;
    System.Uri currentHostUrl = new System.Uri(currentUrl);
     
    UrlGenerator urlGenerator = new UrlGenerator();
    urlGenerator.HostUrl = currentHostUrl.GetLeftPart(System.UriPartial::Authority);
     
  • Basti Aurand Profile Picture
    Basti Aurand 62 on at
    ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()
    These are my debugging options:
     
    My debugging is attatched to "w3wp.exe" and the debugger loads the breakpoint correctly but as soon as I do a ODATA call to the DataEntity via POSTMAN, the debugger crashes:
  • Martin Dráb Profile Picture
    Martin Dráb 225,425 Super User on at
    ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()
    Resolve a problem is very difficult without knowing what the problem is.
     
    Can you tell us more about your problem with debugging? Your description isn't clear to me. Are you saying that your breakpoints in postLoad() are ignored? If so, which process did you attach the debugger to? Do you have debugging enabled for the module? Are you able to use debugger for your other code?
  • Basti Aurand Profile Picture
    Basti Aurand 62 on at
    ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()
    Hi Martin,
     
    thanks for the reply. Unfortunatly I'm struggling with the debugger on my image (always "closed unexpectly..."). Therefore I could not extract a detailed error message. The error arises when executing the following line:
     
     
    Sebastian
  • Martin Dráb Profile Picture
    Martin Dráb 225,425 Super User on at
    ERROR deep link code (UrlHelper.UrlGenerator()) in DataEntity.postLoad()
    I see that an exception was thrown, but not where and what the error message says. Please use the debugger to get this information. Resolving a problem without enough information is difficult, as you've already found.

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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,876 Super User

#2
Ludwig Reinhard Profile Picture

Ludwig Reinhard Microsoft Employee

#3
Martin Dráb Profile Picture

Martin Dráb 225,425 Super User

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans