/ Dynamics

[X++] Extend parm method template

In my post about find method template I described how to add a new template to the editor.

When we take a look at the existing ones, we can see the parm template. I am sure many of you use this (like me) because it's useful to create parm methods very fast.

Sometimes I struggle with this dialog because I need a parm method returning Common or any other system table or system class.

I used to enter SalesId or something similar in the dialog and then replaced the SalesId type via CTRL+H with the needed return type.
But today I took the time to find out how this can be extended.

Where does the Dialog come from?

The dialog can be found in \Classes\EditorScripts\template_method_parm and uses the EDT SysXppType for the type field. This EDT controls the lookup and validation.

The EDT SysXppType

Taking a closer look on this EDT, we can see it has some restrictions via the relations:
Restrictions EDT Relaion

Find the needed IDs

So first we need to know which IDs the system classes and tables have.
To take an easy example I used the class XmlDocument and the following code in a job:

static void Job9(Args _args)
{
    SysModelElement el;
    
    while select el
        order by Name
        group by Name, ElementType
        where el.Name like 'XmlDocument'
    {
        info(strFmt("%1 => %2", el.Name, el.ElementType));
    }
}

Now we know system classes have the ID 42.

Extend the EDT Relations on SysXppType

Extending the relations on the EDT SysXppType with the ID 42 enables us to select system classes in the parm dialog from now on:

[X++] Extend parm method template
Share this

Subscribe to robsCode