Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

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

(1) ShareShare
ReportReport
Posted on by 175
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
    175 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
    175 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
    233,896 Most Valuable Professional 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
    175 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
    233,896 Most Valuable Professional 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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 601 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 416

#3
Adis Profile Picture

Adis 384 Super User 2025 Season 1

Product updates

Dynamics 365 release plans