ENTERPRISE

Microsoft Dynamics AX 2009 : Building Lookups - Another way of displaying custom options

11/17/2012 12:53:18 AM
Global system functions like pickList(), pickUser() and similar in Dynamics AX allow developers to build various lookups displaying a list of custom options. Besides that, the standard Dynamics AX application contains several additional global lookup functions, which have a slightly richer user interface.

One of the functions is called selectSingle() and presents the user with a list of selectable options created using a container type variable.

In this recipe for demonstration purposes, we will create a job that shows the principle of how to use this function. As sample data, we will use different versions of Dynamics AX.

How to do it...

  1. 1. Create a new job called SysListSelect:

    static void SysListSelectSingle(Args _args)
    
    {
    container choices;
    container sel;
    boolean ok;
    ;
    choices = [
    ["2009\nDynamics AX 2009",1,true],
    ["4.0\nDynamics AX 4.0",2,false]];
    sel = selectSingle(
    "Choose version",
    "Please select Dynamics AX version",
    choices,
    ["Version","Description"]);
    ok = conpeek(sel,1);
    if (ok)
    {
    info(strfmt(
    "You've selected option No. %1",
    conpeek(sel,2)));
    }
    }
    
    
    					  
  2. 2. Run the job to start the lookup:

  1. 3. Select one of the options, and click the OK button. The information message displays the selected option:

How it works...

In this recipe, we first fill in the choices variable with values. Basically, here we build a container of containers. Each container inside the parent container is made of three elements and represents one selectable option in the list:

  1. 1. The first element is a selection text. Normally, it is displayed as one column, but in this example, we can use \n inside the text to create more columns.

  2. 2. The second element is the number of the list item. This value is returned upon user choice.

  3. 3. And the third value specifies whether the option is preselected by default.

Once list values are ready, we call selectSingle() to build the actual lookup. This function accepts five arguments:

  1. 1. Window title.

  2. 2. Lookup description.

  3. 3. A container of list values, in our case, choices.

  4. 4. A container representing column headings, in our case, Version and Description.

  5. 5. A reference to a caller object, normally a Dynamics AX form or control. In this example, we do not use this parameter.

singleSelect() returns a container of two elements:

  1. 1. true or false depending if the lookup was closed using the OK button.

  2. 2. The key value of the user-selected option.

There's more...

You may have noticed that the lookup, which is created using singleSelect(), allows choosing of only one option from the list. There is another similar global function called selectMultiple(), which is exactly the same except that the user can select multiple options from the list. The following code demonstrates its usage:

static void SysListSelectMultiple(Args _args)

{
container choices;
container sel;
boolean ok;
int i;
;
choices = [
["2009\nDynamics AX 2009",1,true],
["4.0\nDynamics AX 4.0",2,false]];
sel = selectMultiple(
"Choose version",
"Please select Dynamics AX version",
choices,
["Version","Description"]);
ok = conpeek(sel,1);
if (ok)
{
for (i=1; i <= conlen(conpeek(sel,2)); i++)
{
info(strfmt(
"You've selected option No. %1",
conpeek(conpeek(sel,2),i)));
}
selectMultiple() functionselectMultiple() functionabout}
}


					  

Once the lookup is opened, you can select multiple options:

After clicking OK button, the information message shows selected options:

Note that here the second value of the returned container is a container of selected key values.
Other  
 
Top 10
Review : Sigma 24mm f/1.4 DG HSM Art
Review : Canon EF11-24mm f/4L USM
Review : Creative Sound Blaster Roar 2
Review : Philips Fidelio M2L
Review : Alienware 17 - Dell's Alienware laptops
Review Smartwatch : Wellograph
Review : Xiaomi Redmi 2
Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
Popular Tags
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone