vendredi 26 novembre 2010

How to create a Lookup Form and use it as a formHelp Proprety of an ExtendedDataType in Dynamics AX

To create a Lookup Form in Dynamics AX, just create a form and add in the DataSources the table from which you want to get fields  : for example your need to get the emplId field from the table EmplTable: You can filter the field in the executeQuery method of this Table:

public void executeQuery()
{
    PayrollPaySlipJour                                    payrollpayslipjour;
    PayrollEmployee                                       payrollemployee;

    select  emplid from empltable exists join payrollpayslipjour join payrollemployee 
                                  where payrollpayslipjour.emplid== empltable.emplid
                                  && payrollemployee.EmplId == empltable.EmplId
                                  && payrollemployee.PayrollResignationClose == false;
}

In the init Method use this code: 

void init()
{
    Query   query = new Query();
    ;
    super();

    query.addDataSource(tablenum(empltable));

    this.query(query);
}

Then in the init method of the form use this code: 

void init()
{
    ;
    super();
    element.selectMode(EmplTable_EmplId);
}

Then add a Grid in the design of the from and add the fields you want besides of the field: EmplTable_EmplId whose Auto Declaration proprety must be set to yes .

Don't forget to set the following properties on the datasource, so that the form can not be used for editing:
       AllowCheck:    No
      AllowCreate:   No
      AllowDelete:   No
      AllowEdit:     No
      AutoNotify:    No
      InsertAtEnd:   No
      InsertIfEmpty: No
Additionally set for the design the following properties to make it look like a proper lookup:
         AlwaysOnTop:   Yes
      Frame:         Border
      HideToolbar:   Yes
      WindowType:    Popup

You can use it in the ExtendedDataType where you set the formHelp proprety to the name of this form.
Then whenever you call this field, you'll have this Lookup form displayed.
For example , I called it in a dialog and I got this:




You can always refer to http://www.axaptapedia.com/ Here is the link: 

http://www.axaptapedia.com/Lookup_Form

You can also define an EDT with a relation , when you set the EDT for a field you get your lookUp form.


Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire