A man didn’t understand how televisions work, and was convinced that there must be lots of little men inside the box, manipulating images at high speed.  An engineer explained to him about high frequency modulations of the electromagnetic spectrum, about transmitters and receivers, about amplifiers and cathode ray tubes, about scan lines moving across and down a phosphorescent screen. The man listened to the engineer with careful attention, nodding his head at every step of the argument. At the end he pronounced himself satisfied. He really did now understand how televisions work.
 "But I expect there are just a few little men in there, aren’t there?" -Douglas Adams

AX7: MetaModel in D3FO to get a list of tiles for every workspace

posted Apr 25, 2018, 2:33 PM by d graham   [ updated Apr 25, 2018, 2:35 PM ]

Here is an example for how to work with the Dynamics 365 For Finance Operations Enterprise Edition(AX7) meta model in order to obtain some information about AOT objects. 

Forgive the naming and loops on loops on loops... this is just example code.

The example code is provided as-is and without warranty etc etc

using Microsoft.Dynamics.AX.Metadata.MetaModel;
using Microsoft.Dynamics.AX.Metadata.Service;
using Microsoft.Dynamics.AX.Metadata.Providers;
//using Microsoft.Dynamics.AX.Metadata.Kernel;

class TestClass

    public static void Main(args _args)
        var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory::GetApplicationEnvironment();
        IMetadataProvider p = TestClass::getRunTimeMetadataProvider(environment);
        IMetaModelService service = new MetaModelServiceFactory().Create(p);
        var forms = service.GetFormNames();

        var e = forms.GetEnumerator();
        while (e.moveNext())
            str formName = e.get_Current();
            AxForm form = service.GetForm(formName);
            if(form.Design.Style == Microsoft.Dynamics.AX.Metadata.Core.MetaModel.FormStyle::Workspace)
                var controls = form.Design.GetAllControls();
                var eC = controls.GetEnumerator();
                while (eC.moveNext())
                    AxFormControl curr = eC.get_Current();
                    if(curr is AxFormMenuFunctionButtonControl)
                        AxFormMenuFunctionButtonControl tile = curr;
                        if(tile.FormControlExtension == null)
                        var exp = tile.FormControlExtension.ExtensionProperties;
                        var eExp = exp.GetEnumerator();
                            Microsoft.Dynamics.AX.Metadata.MetaModel.AxFormControlExtensionProperty currProp = eExp.get_Current();
                            if(currProp.Name == 'tile')
                                info(strFmt("workspace: %1 control: %2 tile: %3",

    public static Microsoft.Dynamics.AX.Metadata.Providers.IMetadataProvider
            getRunTimeMetadataProvider(Microsoft.Dynamics.ApplicationPlatform.Environment.IApplicationEnvironment _environment)
        Microsoft.Dynamics.AX.Metadata.Storage.Runtime.RuntimeProviderConfiguration runtimeProviderConfiguration
                = new Microsoft.Dynamics.AX.Metadata.Storage.Runtime.RuntimeProviderConfiguration(_environment.get_Aos().get_PackageDirectory());

        Microsoft.Dynamics.AX.Metadata.Storage.MetadataProviderFactory metadataProviderFactory
                = new Microsoft.Dynamics.AX.Metadata.Storage.MetadataProviderFactory();

        return metadataProviderFactory.CreateRuntimeProvider(runtimeProviderConfiguration);


Find security duties related to menu item in Dynamics AX 7(365 for Operations)

posted Mar 1, 2017, 10:16 PM by d graham   [ updated Mar 3, 2017, 12:28 AM ]

using Microsoft.Dynamics.AX.Security.Management;
using Microsoft.Dynamics.AX.Metadata.Providers;

class jTest
    public static void main(Args _args)
        jTest j = new jTest();
        SecurityRepository sr = new SecurityRepository(null, null);
        Querying.RelatedSecurityRolesFinder rsrf = new Microsoft.Dynamics.AX.Security.Management.Querying.RelatedSecurityRolesFinder(sr);

        j.getDisplayRelatedDuties("PurchTable", rsrf);
        j.getOutputRelatedDuties("PurchInvoice", rsrf);
        j.getActionRelatedDuties("PurchTableApprovalApprove", rsrf);

    private void getActionRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemAction(_actionMenuItem);

    private void getDisplayRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemDisplay(_actionMenuItem);

    private void getOutputRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemOutput(_actionMenuItem);

    private void displaySobDuties(SecurityObjectsBag _sob)
        using(var dutiesEnumerator = _sob.Duties.getEnumerator())
                Interfaces.ISecurityObject d = dutiesEnumerator.Current;
                info(strFmt("%1, %2", d.Name, d.Identifier));


Locating an AX7 entity field from the form control

posted Feb 3, 2017, 9:28 AM by d graham

1.   Find the form in the Application Explorer under UI elements and right click to view the design
2.       If the preview comes up find the control in the preview and Visual Studio will select it in the designer, or if the preview doesn’t come up then dig down into the many levels of tabs and groups to search for the form contro
3.       In the properties for the form control it will have a property for Data Source and for Data Field
4.       The Data Source property will tie back to the form data sources which will have a Table property   
5.       A Find references lookup from Application Explorer>Data Model>Tables on the PriceUnit field on InventTableModle will help to get back to the entity for data import, where it looks like AX is calling it PurchasePriceQty    

TLS version in Dynamics AX .net interop in X++

posted May 26, 2016, 10:23 AM by d graham   [ updated May 26, 2016, 10:29 AM ]

Recently in my office a discussion about which version of TLS is used by Dynamics AX in .net interop calls came up, as a vendor announced that in the next year TLS1.0 and TLS1.1 would be disabled for access to their API.

The setting that seems to control which protocols are available for web requests can be set with the following:

set_SecurityProtocol() will accept a bitmask value based on the System.Net.SecurityProtocolType enum:

It seems that the .net setting for System.Net.ServicePointManager.SecurityProtocol is set per AppDomain ( ) which means that potentially setting that enum value for a specific vendor may have side effects on your other API integrations(if such exist). If you must select a specific protocol for a vendor it may be worth considering creating the call in it's own AppDomain.

To determine what the current value of System.Net.ServicePointManager.SecurityProtocol in your AX .net environment you can run a job like so:

    static void CheckEnviornmentSecurityProtocol(Args _args)
        int i;
        boolean ssl3Enabled,tlsEnabled,tls11Enabled,tls12Enabled;
        i = System.Net.ServicePointManager::get_SecurityProtocol();
        ssl3Enabled = i & enum2int(System.Net.SecurityProtocolType::Ssl3);
        tlsEnabled = i & enum2int(System.Net.SecurityProtocolType::Tls);
        tls11Enabled = i & enum2int(System.Net.SecurityProtocolType::Tls11);
        tls12Enabled = i & enum2int(System.Net.SecurityProtocolType::Tls12);
        info(strFmt("'%1' enabled: '%2'",
        info(strFmt("'%1' enabled: '%2'",
        info(strFmt("'%1' enabled: '%2'",
        info(strFmt("'%1' enabled: '%2'",

rootron5: how to root the retron 5

posted Aug 8, 2014, 1:13 AM by d graham

First, I would like to say that I am a big fan of the retron 5, I think it's a great device--anyone who likes retron video games should go buy one... 

I think this is the first public rooting of the Hyperkin Retron5, and I only soft-bricked my console once on the way, so I am pretty excited to share this with the world.

    -the controller will not be able to charge using the port on the retron while this is in use afaik 
    -this is only tested once on my device
    -usb settings are probably wonky so I wouldn't play too much with usb types other than adb unless that gets cleaned up

1. grab the factory restore from the hyperkin website:  (maybe someone could mirror that incase hyperkin pulls the files)
2. follow the standard instructions until your sd card is formatted and has a file called on it (as a side note there is a neat magic number header on the sd card you can look at with a hex editor that causes the retron to mount data and cache on the sd card instead of the standard mount point)
3. delete the update.img from the sd card and replace it with the copy attached at the bottom
4. now continue to follow the standard instructions and flash the update with the retron recovery
5. connect with a mini usb and adb should be enabled and have root! enjoy!

this is kind-of a messy/hacky job on the update, but it's good enough for now.

Lots of interesting stuff in the stock rom:
 -check out retrondummy.apk or something like that for what looks like the lists of games supported (and probably with a small bit of reversing you could add your own games to the txt files) 
 -a cool chip tunes song (maybe they used for testing audio?)
 -the horse head picture that retron tech uses on facebook (and some other pics which maybe seem like easter eggs from the developers or something?)
 -retronUpdater seems like maybe it has the key for how the application files get decoded or something?
 -looks like the carts are probably having chr and prg dumped for nes, so I'm guessing the cart is just for show after the dump
 -it looks like it probably tries to run if it exists on the data partition as part of init.rc


many thanks to my coworkers/friends and family who have been listening/helping me reach this goal! (glad I didn't have to buy that sdcard protocol analyzer I was looking at or desolder anything!)

Create return order in Dynamics AX 2012 using AIF with ReturnReturnOrderInService

posted Jul 17, 2014, 2:11 PM by d graham   [ updated Jul 17, 2014, 2:14 PM ]

I couldn't find any examples of this on the net, so here is an example of how to use AIF to create a return order in Dynamics AX 2012.

Note: this is sample code only and should probably not be used in production, is without any warranty, and may be missing fields etc

public static AifEntityKeyList createReturnOrder(SalesTable _salesTable)
    SalesLine                           salesLine;
    AifEntityKeyList                    AifEntityKeyList;
    AxdReturnOrderIn                    AxdReturnOrderIn;
    ReturnReturnOrderInService          rrois = ReturnReturnOrderInService::construct();
    ReturnReturnOrderIn                 ret = new ReturnReturnOrderIn();
    AfStronglyTypedDataContainerList    salesTableList, salesLineList, inventDimList;
    ReturnReturnOrderIn_SalesTable      rroiSalesTable;
    ReturnReturnOrderIn_SalesLine       ReturnReturnOrderIn_SalesLine;
    ReturnReturnOrderIn_InventDim       ReturnReturnOrderIn_InventDim;
    AxdReturnOrderIn = ret.getAxdInstance();
    salesTableList = ret.createSalesTable();
    rroiSalesTable = salesTableList.addNew();
    salesLineList = rroiSalesTable.createSalesLine();
    while select salesLine
        where salesLine.SalesId == _salesTable.SalesId
        ReturnReturnOrderIn_SalesLine = salesLineList.addNew();
        inventDimList = ReturnReturnOrderIn_SalesLine.createInventDim();
        ReturnReturnOrderIn_InventDim = inventDimList.addNew();
    AifEntityKeyList = rrois.create(ret);
    return AifEntityKeyList;

Scripting with IronPython in cdmaDevTerm

posted Jan 3, 2013, 10:06 PM by d graham   [ updated Feb 27, 2013, 6:02 PM ]

The new version of cdmaDevTerm(2.85 as of writing) features the ability to use iron python and script against cdmaDevLib directly.  Using IronPython finally provides the power and expressiveness required to script cdma flashes for carriers like PagePlus, MetroPCS and others(which I had received a few emails about with the previous xml based scripting system). I'm no IronPython guru, and you don't have to be either to achieve most basic tasks with cdmaDevLib--but the power of IronPython really does mean the only limit is that of your imagination.

There are two scripts included with .2.85: an attempt at a Cricket flashing script(untested), and a script to show a few examples of how to use the scripting system that comes up by default.

Here's the cricket script:

# sample carrier(cricket) flashing
# cdmaDevTerm ironPython script
# copyright 2012 dg,
mdn = "0000000000"
min = "0000000000"
user = mdn + ""
password = "cricket"

cdmaTerm.Connect(phone.ComPortName)#selected port in cdmaDevTerm
#cdmaTerm.UnlockMotoEvdo() #uncomment for moto nvitem 8035

The cricket script shows a few basic ideas too, like how to declare a variable(ex mdn = "0000000000") and that a comment starts with the # character. You may also realize if you read the cdmaDevTerm source that cdmaTerm.thePhone has been aliased to phone and cdmaTerm.Q has been aliased to q because of frequent use in scripts.

#cdmaDevTerm sample ironPython script #2
#copyright 2013 DG,

#nv = CommandFactory.GetCommand(NvItems.NvItems.NV_SCM_I)
nv = CommandFactory.GetCommand(NvItems.NvItems.NV_MEID_I)
#clear the default system log data
phone.LogData = ""

#this bit seems to show either a badly named method, bug or both

This script shows how a command object is passed by ref and can be used to retrieve the result of the serial IO from the command(it is returned as a byte[] which has the extension method .ToHexString()).

It also seems to show a bug in the .2.85 release, though I need to track down just where that bytesRxdLessHdlc is actually being used.

These few examples came up in an issue discussion re: nv items on google code.
To write an nv item using the decimal value of the nv item, one can do something like this:

     cdmaTerm.WriteNv(906,"505050617373776F7264".ToHexBytes()) which is using cdmaTerm.WriteNv(ByVal nv As Integer, writeData() As Byte) also I think there is a helper method(GetNvWriteDataByteList) for the cdamDevTerm ui which allows the(slightly hacky) but equivalent:     cdmaTerm.WriteNv(906,"0x505050617373776F7264")

Adding Elysium for Windows 8/WP7 style in Win 7 using WPF with C#

posted Sep 26, 2012, 7:27 AM by d graham   [ updated Jul 1, 2013, 5:32 PM ]

Elysium is a 'Windows 8 style', open source, theme component released under the MIT license which is both free as in beer/soda and free as in speech.  I have decided to include Elysium in CdmaDevTerm(an open source project I develop).

Elysium provides two Windows 8 style themes which come in "Light" and "Dark"


 and Dark: - is where the project hosting is, it is also available via nuGet now though.

In order to add Elysium to your project, grab the handful of .dll files which come with the example project which is provided by the authors and add them to your project:


Then on your xamal file add the name space bellow to the Window and preface the Window tag with the new namespace (metro:Window) :

You will also have to change the class the main window inherits from in the code-behind file:
public partial class MainWindow : Elysium.Theme.Controls.Window

Then the last trick is in the main App.xamal you are going to want to add something like this:
                <ResourceDictionary Source="/Elysium.Theme;component/Themes/Generic.xaml"/>
            <!--Bug in .Net 4:>
            <Style TargetType="{x:Type Window}"/>

The theme may be changed by calling for example:


which accepts as a parameter your choice of accent color.

techfail: shopping for home free <Vspan>, aqua teen hunger fail, and career openings: web developer...

posted Aug 10, 2012, 5:10 PM by d graham   [ updated Jul 4, 2013, 8:07 AM ]

Sometimes tech fails...and on with the fail* (a mini homage to

*note: I document the fail not to blame, I just think it's interesting when software manifests itself in strange/funny ways

1-10 of 21