Search This Blog

Monday 28 July 2014

How to filter the form from one Tabpage to another Tabpagen in AX

Hi,

Today I would like to share you how to filter the form from one Tab page to another Tab page .

For an Example i have two Tabpage in my Form
i)Accepted Sheet
ii)Rejected Sheet

When i click Accepted Sheet TabPage , the accepted sheet records must be shown.
Similar way if i click Rejected Sheet TabPage , the rejected sheet records must be listed.

Step 1:

Write the piece of code in the DataSource level executequery ()

public void executeQuery()
{

    this.Query().datasourceNo(1).clearRanges();
   
    if(AcceptedTabPge.isActivePage())
    {
        this.query().dataSourceName('SheetTable')
        .addRange(fieldnum(SheetTable,SheetAccepted)).value(queryvalue(NoYes::Yes));

    }
    if(RejectedTabPage.isActivePage())
    {
        this.query().dataSourceName('SheetTable')
        .addRange(fieldnum(SheetTable,SheetAccepted)).value(queryvalue(NoYes::No));
    }

    super();
   
}

Step 2:

write this piece of code in the pageactivated method of both Tabpage

public void pageActivated()
{
    super();
    SheetTable_ds.executeQuery();
}

Output:

TabPage 1:
 TabPage2:






Happy Daxing......

Sunday 27 July 2014

How to add Search/ Find /Filter functionality to Display method in dynamics AX

Hi,

I have gone through a wonderful blog , where they have explained clearly how to add search/find/filter functionality to display method in dynamic AX

click here

Happy Daxing......

Dialog Events(Modified, lookups ) in AX 2009

Hi ,

Today i would like to share you how to do look-up filtration , modified method in dialog using dialog class

lookup :

void Fld5_1_lookup()
{
     Formrun                 fr = dialog.formRun();
    object                  Control = fr.controlCallingMethod();

    SysTableLookup          sysTableLookup =
    SysTableLookup::newParameters(tablenum(CEKMasterCostCardTable),  fieldMccId.fieldControl());
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    ;


    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, AccountNum),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Name),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Type),true);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Active),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, MccId),false);


    queryBuildDataSource = query.addDataSource(tablenum(CEKMasterCostCardTable));
    queryBuildRange =         queryBuildDataSource.addRange(fieldnum(CEKMasterCostCardTable,AccountNum));
    queryBuildRange.value(queryvalue(fieldCustAccount.value()));


    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(false);
    sysTableLookup.performFormLookup();
}

modified :

public boolean Fld2_1_modified()

{
    FormCheckBoxControl control = dialog.formRun().controlCallingMethod();

    boolean isFieldModified;
    ;

    isFieldModified = control.modified();


    if(isFieldModified)
    {
        filedChkNewCard.value(0);
        fieldCustAccount.allowEdit(false);
        fieldMccId.allowEdit(false);
   
    }

    return isFieldModified;

}

dialog:

protected Object dialog()
{

    ;
    dialog = super();

    dialog.caption("Select  One of three below options or cancel");

    dialog.allowUpdateOnSelectCtrl(true);

   fieldChkBlankCard=dialog.addField(Typeid(NoYes),"Create New Blank Cost Card");
   fieldChkSelectedCard=dialog.addField(Typeid(NoYes),"Copy from selected "+cEKMasterCostCardTable.Name+','+cEKMasterCostCardTable.Type+','+cEKMasterCostCardTable.MccId);
   filedChkNewCard=dialog.addField(Typeid(NoYes),"Copy from Other Customer");

    fieldCustAccount    = dialog.addField(typeid(CustAccount)," Customer ID");
    fieldMccId = dialog.addField(typeid(CEKMccId),"MCC ID");
    fieldType=dialog.addField(typeid(str200),"Type");

    fieldText=dialog.addField(typeid(Notes));

    okButton = dialog.formBuildDesign().control('OKButton');

    okButton.enabled(false);

    return dialog;
}

dialogPostRun:

public void dialogPostRun(DialogRunbase  _dialog)
{
    super(_dialog);
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

pack:

public container pack()
{
    return connull();
}

unpack:

public boolean unpack(container packedClass)
{
    return true;
}

class delcaration:

class CEKMasterCostCardDialog extends RunBase
{
    DialogField fieldCustAccount;
    DialogField fieldMccId,fieldText,fieldType;
    DialogField fieldChkBlankCard,fieldChkSelectedCard,filedChkNewCard;
    FormBuildCommandButtonControl   okButton;
    CEKMasterCostCardTable cEKMasterCostCardTable;
    str Mcc;

    Dialog          dialog;

}
main:

public static void main(Args args)
{

    CEKMasterCostCardDialog cekMasterCostCardDialog;
    CEKMasterCostCardTable cekMasterCostCardTable;
    ;

    cekMasterCostCardDialog = new   CEKMasterCostCardDialog();

    if(cekMasterCostCardDialog.prompt())
    {
    cekMasterCostCardDialog.run();
    }

}

click here for the syntax in Dialog class.

click here  for detail explanation.


Happy daxing.....


Friday 25 July 2014

Inserting Space between the characters in a String in Ax


Hi,

Today I would like to share you x++ code to insert space between the characters in a string in AX.

Example 1:

static void insertSpaceBtwString(Args _args)

{

str s,s1;

int i,j;

s="KORCOMPTENZ";

j= strLen(s);

for(i=1;i<=j;i++)

{

   s1=s1+subStr(s,i,1);

  if(i!=strLen(s))

  s1=s1+ " ";

}

info(s1);

}

Output:
 
 
 
Example 2:
 
Inserting space after each four digit Number
 

static void InsertSpace(Args _args)

{

str s,s1;

int i,j;

s="1245678945612355";

j= strLen(s);

for(i=1;i<=j;i=i+4)

{

    s1=s1+subStr(s,i,4);

    if(i+4<=j)

    s1=s1+" ";

}

info(s1);

}

Output:
 
 
 
 
 
Happy Daxing....


 

Wednesday 9 July 2014

Valid Time State Tables in Dynamics AX 2012 [ValidTimeStateFieldType]


Hi Guys,

In DAX 2012, we can let the system manage data relationships that are valid only during a specified date range.
This can be achieved by setting “ValidTimeStateFieldType” property on the table.The system then adds the ValidFrom and ValidTo columns that track a date range in each row. The system guarantees that the values in these date fields remain valid by preventing overlap among date ranges, based on the primary key value.
Let me explain with an example. Let us create a new table with a new string field “Name” which extends Name EDT.
Right click on the table and set the ValidTimeStateFieldType property to utcdateTime as shown below

After setting this property, system will automatically create ValidFrom and ValidTo fields in your table as shown below

Create a new Index by name NameIdx and drag drop Name, ValidFrom, ValidTo fields on to the index and set the following properties on your newly created index as shown below.

You can set the NameIdx as replacement Key on the table.
Now open the table and start entering the data. you will notice that ValidTo will be automatically defaulted to maxdate() 12/31/2154[Never] and validFrom to system date and time now as shown below.



Happy Daxing....

X++ code to open the Excel as Read Only Mode


Hi Guys,

setFileAttribute method is used to open the file in read only mode , but mode value must be 1

Example:

filename= "C:\Users\chagirathi\Desktop\Master Cost Card Field Maping (1).xlsx";
Winapi::setFileAttributes(filename,1);

Happy Daxing....

X++ code to Count Records in Query


Hi Guys,

The below code is used to count records in query.


static void Query_cntRecords(Args _args)
{
    Query                query = new Query();
    QueryRun             queryRun;
    QueryBuildDataSource qbd;
   
    
    qbd = query.addDataSource(tablenum(CustTable));
    queryRun = new QueryRun(query);
   
    info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun)));
   
}

Happy Daxing......

Removing Leading Zeros from a String

Hi Guys,

click here to get the X++ code "how to remove the leading Zeros from a sting in AX?"

Happy Daxing.....

Installation and configuration of EP in AX 2012 R2

Hi Guys,

Today I have referred a wonderful blog where they have neatly explained how to do installation and configuration of EP in AX 2012 R2.

click here

Happy Daxing......
 

Opening Google Webpage using ActiveX control in AX 2012 R3 Forms

Hi ,

Today i am going to share you , how to navigate to webpage using ActiveX control in AX 2012 R3 Form .

Step1:

Create New Form named as WebBrowserForm



Step 2:

Right click the Design node and select ActiveX


Step 3:

Select Microsoft Web Browser from AciveX window


Step 4:

Write some piece of code in init() method of the form

ActiveX.Navigate("www.google.com");

 
Output:

Thus Google page is displayed in AX Form.

Happy Daxing....