What handles dynamics:// URLs?
Asked Answered
O

2

5

I'm trying to create my own custom drilldown functionality, where a URL dynamics://0?myfunction_123456 will launch my own code.

In C\SysStartupCmd\construct, this base code:

    case 'viewalert':
        sysStartupCmd = new SysStartUpCmdViewAlert(s,parm);
        break;
    case 'drilldown':
        sysStartupCmd = new SysStartUpCmdDrillDown(s,parm);
        break;
    case 'viewalertrule':
        sysStartupCmd = new SysStartUpCmdViewAlertRule(s,parm);
        break;

I've tested and these all get fired with these URLs:

  • dynamics://0/?DrillDown_382576
  • dynamics://0/?ViewAlert_382576
  • dynamics://0/?ViewAlertRule_382576

However, if I add my own case, leaving all other code the same, I can't get the URL to fire:

    case 'myFunction':
        sysStartupCmd = new SysStartUpCmdDrillDown(s,parm);
        break;

I've dug all over the system and can't figure out what causes the dynamics:// URL to only fire for those three cases. Is there a registry entry or something? I've found C\EventDrillDownPoller which appears to create a PipeServer to maybe handle what's incoming?

Opine answered 23/1, 2014 at 17:34 Comment(0)
O
6

Of course, I figure out my own answer every time I type up a stackoverflow question, but I think the information is really useful.

This stack question led me to find out that C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin\AxHLink.exe %1 handles Dynamics:// URLs.

Which led me to Microsoft's community forums where somebody else was facing a similar problem as me.

So the solution would be to either:

  • Create custom a URI handler with C# or some other language to communicate to AX (Similar to this)
  • Hi-jack one of the 3 handled existing cases with some custom X++ code to try and fork off of it. Perhaps by changing the drilldown target in the URL and handling that way, or appending some special characters to the string.
  • Call "c:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin\Ax32.exe" -startupcmd=myfunction_myParams and make that a clickable link.
Opine answered 23/1, 2014 at 18:0 Comment(2)
of course you figured out your own problem en.wikipedia.org/wiki/Rubber_duck_debuggingBabysitter
What an awesome way of debugging!Opine
H
6

You have answered your own question, but it is quite easy (if you know how) to hook on the standard DrillDown code to customize AX to start a specific form like:

Starts AX on item 03310511 in company XXX

start dynamics://TEST/?DrillDown_0?table=InventTable&field=itemId&value=03310511&company=XXX

It will assume reasonable defaults.

start dynamics://TEST/?DrillDown_0?table=CustTable&value=113545

And AX can be called from a HTML e-mail, assuming the receiver has an AX client!

<a href="dynamics://TEST/?DrillDown_0?table=CustTable&value=113545">113545</a>

You find my customization in my pastebin.

Harelda answered 23/1, 2014 at 18:40 Comment(8)
Ah fantastic. Very nice code and saved me a bunch of time! One concern with your code though is that when you hook to your custom SysStartupCmd*, you strip out the actual navigation mark of TEST ,in your case, which could cause problems for something more variable like SalesTable, or if somebody uses your code to execute or something. Super useful!Opine
It probably should test that TEST match the value stored in the parameters (as it does in the normal DrillDown code path).Harelda
Yup :). I moved your code in parseDrillDownNavigationMark to a new static method parseDrillDownCustomParam, then switched the code in parseDrillDownNavigationMark back to base, then changed the delimiter line to int delimiter = strscan(parm, '?', strlen(parm), -strlen(parm)); (note the - symbol). Then in C\SysStartUpCmdDrillDown\infoRun, I just moved the if (!EventDrillDownPoller::checkDrillDownNavigationMark(navigationMark)) back above your custom code. Easy fix.Opine
I think there is a MS bug that is causing the drilldowntarget to get stripped out sometimes. The same URL, repeated over and over, sometimes has the drilldown target stripped out. I can't get mine back. I'm guessing a full system compile and restart or something might fix it.Opine
I have tried drilldown links in AX 4, 2009 and 2012. In AX4 and AX2009 the above link ('dynamics://TEST/?DrillDown_0?table=CustTable&value=113545') works and the EventDrillDownPoller class is called. However, in AX 2012 the input is somehow filtered (By AxHLink.exe?) and only int64 parameters are parsed and sent to the EventDrillDownPoller class. 'dynamics://0/?DrillDown_5637230378/' works, but adding any string to the url parameter like 'dynamics://0/?DrillDown_5A/' never reaches the client. I guess the only option is one of @Alex Kwitny 's suggestions: Startupcmd or a custom C# URL handler.Rawley
@TinavanderVyver - You are correct that in AX12 the second part must be an integer, but the drill-down target doesn't have to be. There are two things that are dynamic in the url dynamics://[Drill-down target]/?Drilldown_[Integer]. [Drill-down target] is matched to the configuration in SysAdmin>Setup>SystemParameters, Alerts, Drill-down target. So in that setup, you may have TEST put there, but you can customize \Classes\EventDrillDownPoller\parseDrillDownNavigationMark and then change your URL to be dynamics://TEST_mytext/?DrillDown_12345 and parse the target, not the integer.Opine
^ the above would allow you to pass mytext and do something with it. You could use the integer to be a RecId or something, and the mytext to be an action.Opine
@AlexKwitny - Thank you for the suggestion! I never thought of changing the text of the target. Unfortunately now it doesn't open the link in the correct client instance. I have posted my problem as a new question: https://mcmap.net/q/1923966/-add-custom-text-to-ax-2012-drill-down-links/2552958. Thanks again for the idea, I'll continue hammering away at it till it works.Rawley

© 2022 - 2024 — McMap. All rights reserved.