Thursday, 18 September 2014

Find mandatory Fied in Table



                                      Find Mandatory Field In Table

In Microsoft Dynamics Ax 2012 many table are having mandatory field. Here I would like to share how to find mandatory field in a Table.

For Example CustTable.


The below code uses DictTable and DictField classes to iterate through the table fields and it's properties.

Using these classes you can also check other properties of the fields in a table.

Step 1:-

 Go to job, Create a New job, paste following code in the job and Run the job.


 Step 2:-

static void mandatory(Args _args)

 {
    DictTable       dictTable;  //SysClass

     DictField       dictField;  //SysClass

     int             i, cust;
 
    dictTable = new DictTable(tableNum(CustTable));

     cust= dictTable.fieldCnt();   // fieldCnt- Returns the number of fields for a table//

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

     {
        dictField = new DictField(tableNum(CustTable),dictTable.fieldCnt2Id(i));

                                     //fieldCnt2Id-Returns the field ID of the field that is specified by an index//     

         if (dictField.mandatory())

         {

             info (strFmt("Field %1 is mandatory.",dictField.label()));  //Returns the label for the field//
         }
    }
   
}

Step 3:-

You can see the list of mandatory field in Infolog.



   
 

Monday, 15 September 2014

HOW TO OPEN WEB PAGE FROM AX 2012

Step 1:-

                 Create a From OpenWebPage.

Step 2 :-

                 Under the design node select ActiveX control.


                                 



Step3:-

              Once we select ActiveX Control a dialog prompts, select "Microsoft web browser" option.



 Step 4:-

        After place the following code in form level init method.


public void init()
 
{
 
super();
ActiveX.Navigate(www.bing.com);
 
 
}

 
 
Step 5:-
 
            You can see  Bing Web Page Opening in AX 2012.
 
  

Thursday, 14 August 2014

Simple Steps to Generate Number Sequence In Table Level


Step 1:-
               Create an EDT SerialNo.
Step 2:-
              Select the module which you want to generate number sequence.
Step 3:-

              write the following code load module() on NumberSequenceModuleCustomer.

     datatype.parmDatatypeId(extendedTypeNum(SerialNo));
    datatype.parmWizardIsContinuous(true);
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmWizardHighest(999999);
    datatype.parmSortField(27);
    datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    this.create(datatype);
    this.mcrLoadModules(datatype);

Step 4:-
     
    Write the following code on a New method on CustParameterTable.

client server static NumberSequenceReference numRefSerialNo()
{
     return NumberSeqReference::findReference(extendedTypeNum(SerialNo));
}

Step 5:-
         Write the following code on a Job and Run it.


static void serialNo(Args _args)
{
    NumberSeqModuleCustomer  NumberSeqModuleCustomer = new NumberSeqModuleCustomer();
    ;
    NumberSeqModuleCustomer.load();
}

Step 6:-

        Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

Fill the require Details and Click Generate


Step 7:-

          AccountsReceivable ----> Setup ----> AccountsReceivableParameters ----> NumberSequence

        


Step 8:-

              Create  Table Add the EDT and write following code in initValue() Method.


  public void initValue()

{

  NumberSeq  numberSeq;

 SerialNo num;
 super();
 numberSeq = NumberSeq::newGetNum(CustParameters::numRefSerialNo());
num = numberSeq.num();
this.SerialNo=num;
}

Step 9:-

             Select Cntrl+N Number Sequences is Generated.



   

USING CHECK BOX ENABLE / DISABLE RECORDS WITH THE GRID


Step 1:-

             Create a table and Add some  fields.

Step 2:-

            Add table as a data sources, Create a form.

Step 3:-

          Create a grid under design tab and add fields to the grid.

Step 4:-

           Add a check box to the form.

 Step 5:-



 Write the following code in modified method.

public Boolean modified()
{
boolean ret;
ret = super();
if(checkbox.value()==true)
{
while select CheckBoxTable
{
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,Name)).visible(true);
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,RegNo)).visible(true);
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,Testbox)).visible(true);
}

}
else
{
while select RecId from CheckBoxTable where CheckBoxTable.TestBox == true
{
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,RegNo)).visible(false);
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,Testbox)).visible(false);
CheckBoxTable_ds.object(fieldnum(CheckBoxTable,Name)).visible(false);

}
}

CheckBoxTable_ds.refresh();
return ret;
}


Step 6:-

      Select the check box it will enables the grid.      



OUTPUT:-

       

         Un select the check box it disables the grid.





Tuesday, 12 August 2014

USING COMMAND BUTTON,NEW,DELETE & SAVE THE RECORDS WITHOUT CODING







Step 1:-
            create a table add some fields.

Step 2:-
           Add the newly created table as a data sources to form.

















Step 3:-
           Drag and drop fields in design & Add new buttons.


Step 4:-
       
         Assign button level properties ----> command select the command "Save".





Step 5:-

         As same the above followed by add  New & Delete select the perfect command to perform required action.



Output:-