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;
}