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?

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71

2 Answers2

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.
Community
  • 1
  • 1
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
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.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • 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! – Alex Kwitny Jan 23 '14 at 21:28
  • It probably should test that `TEST` match the value stored in the parameters (as it does in the normal DrillDown code path). – Jan B. Kjeldsen Jan 23 '14 at 21:52
  • 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. – Alex Kwitny Jan 23 '14 at 21:55
  • 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. – Alex Kwitny Jan 27 '14 at 22:34
  • 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. – Tina van der Vyver May 20 '16 at 15:30
  • 1
    @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. – Alex Kwitny May 20 '16 at 19:03
  • ^ 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. – Alex Kwitny May 20 '16 at 19:05
  • @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: http://stackoverflow.com/q/37409624/2552958. Thanks again for the idea, I'll continue hammering away at it till it works. – Tina van der Vyver May 24 '16 at 09:40