Monday, 29 December 2014

ENABLE OR DISABLE THE ROWS IN GRID based On CHECKBOX

STEP 1:

Create a Table with Some Fields.Add all fields into FieldGroup except CheckBox Field.



STEP 2:

Creae a Form and add a table as Datasource.



STEP 3:

Drag and drop the Group and CheckBox Field into Design node.

STEP 4:

Write a code in CheckBox  Control level modified() method:

public boolean modified()
{
    boolean ret;

    EnableDisableRows enableDisableRows11;

    ret = super();

    if(this.value()==boolean::false)
    {
        Group1.enableChilds(true);
    }
    else
    {
        Group1.enableChilds(false);
    }

    return ret;
}

STEP 5:

We can get the output,,

 
 





 

Monday, 22 December 2014

SET BACKGROUND COLOR FOR PARTICULAR RECORD

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    if (_record.(fieldnum(Contributions,Year))=="2011")
    {
     _options.backColor(WinAPI::RGB2int(500,100,255));
    }
    else if(_record.(fieldnum(Contributions,Year))=="2014")
   {
     _options.backColor(WinAPI::RGB2int(101,100,255));
    }

    super(_record, _options);
}


 
BASED ON SALESID GET PRIMARY PHONE NUMBER AND ADDRESS

static void TestJob(Args _args)
{
str a; 
SalesTable salestable;
LogisticsLocation logisticslocation;
LogisticsElectronicAddress logisticsElectronicAddress;
LogisticsPostalAddress logisticsPostalAddress;
select salestable where salestable.salesid=='001731';
select logisticslocation where logisticslocation.ParentLocation ==LogisticsPostalAddress::findRecId(salestable.DeliveryPostalAddress).Location;
info(LogisticsElectronicAddress::findByLocation(logisticslocation.RecId).Description);  
info(LogisticsElectronicAddress::findByLocation(logisticslocation.RecId).Locator);
}

 
BASED ON CUSTOMER GET PRIMARY PHONE NUMBER AND ADDRESS

static void TestJOb(Args _args)
{
CustTable custTable;
DirPartyPostalAddressView  dirPartyPostalAddressView ;
LogisticsEntityLocationView  logisticsEntityLocationView ;
LogisticsLocation logisticsLocation ;
LogisticsElectronicAddress logisticsElectronicAddress;
str aa;
select custTable where custTable.AccountNum=="US-005";
info(custTable.address());
aa=custTable.address();
while  select dirPartyPostalAddressView
{
if(dirPartyPostalAddressView.Address==aa)
{
select logisticsEntityLocationView  where logisticsEntityLocationView.EntityLocation==dirPartyPostalAddressView.RecId;
select logisticsLocation where logisticsLocation.ParentLocation==logisticsEntityLocationView.Location;
select logisticsElectronicAddress where logisticsElectronicAddress.Location==logisticsLocation.RecId;
info(logisticsElectronicAddress.Description);
info(logisticsElectronicAddress.Locator);
}
}

}

 

Friday, 19 December 2014


Passing Multiple Records from Form to Report

Step 1: Input Form: Create an Input Form as given Below this will act as first step.





Step 2: Button Clicked: Create a Button which will contain a clicked method which can help in transferring data(records) from form to reports.

void clicked()
{
CustTable    custTable1;
container    con;
Args            args;
str               multiSelectString;

ReportRun reportRun;

args = new Args();

while select custTable1 where custTable1.Checker==boolean::true
{

//Checker is our field

con = conIns(con,1, custTable1.AccountNum);

multiSelectString = con2Str(con, ',' );

}


args.parm(multiSelectString);

args.name(reportstr(ReportCusty_GV));

//ReportCusty_GV is Report Name.

reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportRun.run();
}


Step 3: Create a Report with necessary designs.

Step 3.1: Init Method: Write the below mentioned code in init() method to get values from the form.


public void init()
{
str multipleRecords;

super();

multipleRecords = element.args().parm();
this.query().dataSourceTable(Tablenum(CustTable)).addRange(fieldNum(CustTable,AccountNum)).value(multipleRecords);


}
































EDIT AND DISPLAY METHODS IN AX 2012


EDIT METHOD:


Edit CustAccount custItemGroupId(boolean _set , CustAccount _custItemGroupId)
{
CustTable custTable;
;
if(_set)
{
if(_custItemGroupId)
{
ttsbegin;
custTable = CustTable::find(this.ID,true);
                                         // this mention our Table and ID is  our field
custTable.AccountNum = _custItemGroupId;
custTable.update();
ttscommit;
}
}
else
{
_custItemGroupId = CustTable::find(this.ID).AccountNum;
}
return _custItemGroupId;
}


DISPLAY METHOD


Display CustAccount custItemGroupId1 ()
{
CustTable custTable;
;
return CustTable::find(this.ID).AccountNum;
}

Monday, 10 November 2014

Based on Barcode Populating Item Details Including Dimensions in TransferLine

Based on Barcode populate Item Details including Dimensions in TransferLine

Note:

The bar code for each item is available in the "InventItembarcode" table and refer this table to understand about "bar code".

Steps:

1.create a new field "barcode" in InventTransferTable table and drag and drop the field into table grid in the InvenTransferOrders form.




2.Craete the same field in InventTransferLine table also ,and drag and drop the field into table grid in the InvenTransferOrders form.

3.When we select a new barcode in the header table, All item details will be populated and the same will be inserted as new line in the transfer screen including all the dimensions like color, size and serial numbers.

It is possible to add multiple lines for the same transfer order [same item can also be inserted with different bar code]




4.If the selected bar code is already used by the same or any other transfer orders,
  then it should prompt an error with that existing transfer order number [Eg:"The bar code is already    exist in the Transfer order 000008"]



5.The bar code field in the header should be empty each time after the selection of bar code .

6.So write the code in the Modified() method of the barcode field in Datasourse "InventTransferTable"


public void modified()
{
    InventTransferTable _inventTransferTable;
    InventTransferLine line,line1;
    InventItemBarcode _InventItemBarcode;
    InventDim inventDim1;

    super();


         if(InventTransferTable.itemBarCode)

          {
                 if(InventTransferTable.validateWrite())

                   {
                     select _InventItemBarcode where                      _InventItemBarcode.itemBarCode==InventTransferTable.itemBarCode;

                           if(_InventItemBarcode)

                            {

                             line.initValue();

                             line.initFromInventTableModule(InventTableModule::find(line.ItemId,ModuleInventPurchSales::Invent));

                             line.initFromInventTransferTable(InventTransferTable,true);

                             line.itemBarCode=_InventItemBarcode.itemBarCode;

                             line.ItemId=_InventItemBarcode.itemId;

                             line.LineNum=InventTransferLine::lastLineNum(InventTransferLine.TransferId)+1.0;

                             select InventDim where InventDim.inventDimId==_InventItemBarcode.inventDimId;

                             line.InventDimId=InventDim.inventDimId;

                                               if(line.validateWrite())

                                                 {
                                                   select ItemBarCode from line1 where line1.itemBarCode==line.itemBarCode ;

                                                      if(!line1)
                                                        {
                                                            line.insert();
                                                        }
                                                      else
                                                        {
                                                           InventTransferTable.itemBarCode = " ";
                                                           select TransferId from line1 where line1.itemBarCode ==           line.itemBarCode;
                                                           throw error("Barcode Already Exist in Transfer Order"+"   "+ line1.TransferId);
                                                        }

                                                  }

                               }


                      }

              InventTransferTable.itemBarCode = " ";

              InventTransferLine_ds.executeQuery();


       }


}


Now you can run the form and get the output.....................................