Search This Blog

Monday 29 September 2014

Cascade+Restricted Concept in Ax 2012



Step 1:
Create 3 tables for an example :

Table 1- SheetTable, with Two fields Sheetid and sheetname
Table 2-PartitionTable with three fields sheetid , partitionid and sheetsize
Table 3-SheetPartitionTable with two fields partitionid and Shape 

Step 2:

1) Create a relationship between SheetTable and PartitionTable (Ex:PartitionTable.SheetID==SheetTable.SheetId) 

2) Create a relationship between PartitionTable and SheetPartitionTable(EX:SheetPartitionTable.PartitionID==PartitionTable.PartitionID)

Step 3:

1) Create Cascade DeleteAction between SheetTable and PartitionTable

2) Create Cascade+Restricted DeleteAction between PartitionTable and SheetPartitionTable

Step 4:
Open SheetTable and delete the matched record with PartitionTable.

Automatically the matched record from SheetTable , PartititonTable and SheetPartitionTable will be deleted .

Wednesday 17 September 2014

Virtual Company and Table Collection in AX 2012

Hi ,

Today i would like to share you how to create Virtual company and Table collection.

Step 1:

AOT----Data Dictionary ----Table collection----New Table Collection

Step 2:

Drag and Drop the Tables which you have decided to share

Example i have added PartitionTable(User Created Table)



Step 3:

Go to Administration -- Setup -- Virtual company accounts, and create a virtual company

Note: Before doing the above steps, make sure you are the Ax administrator and the only user online.

















Step 4:

Click Company Accounts Tab and select the Company which you have decided to access the Share Data















Step 5:

Click Table Collection Tab and Select the Table Collection















That's it Virtual Company is created.

Now your data will be available in Selected Company


Output:


TSC and LISP company are available Under Virtual Company.

Therefore the data's are display.

Note: DataAreaID for these data are VC





A&C company is not available under Virtual Company

Therefore data's are not displayed





Thursday 4 September 2014

How to display Employee Image in Ax 2009 Report

Hi ,

Today i would like to share you how to display employee image in Ax 2009 report.

Step 1:

Attach Image to each Employee Record , using Document Handling Attachement

Go to Human Resource->Common Forms-> Employee Details

Step 2:

AOT->Reports->New Report

for an example , My Report name is EmployeeDetailsReport

Step 3:

Add EmplTable as Datasource to display Employee Details

Step 4 :

Write a display method with return type Bitmap to get the employee Image


 To Retrieve Employee Image from Document Handling

display Bitmap emplImage()
{
    Bitmap bitmap;
    Bindata binData = new BinData();
    Docuref docuref;
    Image image;
    ;
    select firstonly docuRef order by docuRef.modifiedDateTime desc where
        docuRef.RefCompanyId == curext() &&
        docuRef.RefRecId == EmplTable.RecId &&
        docuRef.RefTableId == EmplTable.TableId &&
        docuRef.TypeId == "Image";

    if (binData.loadFile(docuRef.completeFilename()))
    {
        bitmap = binData.getData();
    }

    return bitmap;
}

To retrieve Employee Name 

display Name EmplName()
{
;
return DirpartyTable::find(EmplTable.PartyId).Name;
}
Step 5:

Drag and Drop the emplname() and emplImage() method to design



Output:



Wednesday 3 September 2014

How to create Number Sequence in Table Level in Ax 2009

Hi ,

Today i would like to share you how to create Number sequence in Table level in Ax 2009.

Step 1:

Create an EDT  SheetID

Step 2:

NumberSequenceReferences stores all the references and their corresponding numberseq codes

For an Example, create NumberSequence Reference under Accounts Payable Module

Go to AOT->Classes->NumberSeqReference_Vendor

Step 3:

Write a piece of code in loadmodule() of NumberSeqReference_Vendor class

    numRef.DataTypeId               = typeId2ExtendedTypeId(typeid(SheetId));
    numRef.ReferenceHelp            = literalstr("Unique key, allocated to a Presentation");
    numRef.WizardContinuous         = false;
    numRef.WizardManual             = NoYes::No;
    numRef.WizardAllowChangeDown    = NoYes::No;
    numRef.WizardAllowChangeUp      = NoYes::No;
    numRef.SortField                = 12;

    this.create(numRef);

Step 4:

Override the initValue() in Table (Eg:SheetTable)

public void initValue()
{
    NumberSeq       NumSeq;
    ;
    super();
    NumSeq =  NumberSeq::newGetNum(SheetTable::numRefSheetId(),true);
    this.SheetId = NumSeq.num();

}

create a new method to get NumRefID

public client server static NumberSequenceReference numRefSheetId()
{
    ;

    return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(sheetId)));
}

Step 5:

Go to Basic->Setup->Number Sequence->Number sequence

Press Ctrl+N and create a new NumberSequenceCode

For an example i have created a code - KOR_123



Step 6:

Go to AccountPayable->Setup->Parameter
Click NumberSequence Tab


Output:

Happy Daxing...

How to change the Background Color for every form in Dyanmics AX

Hi ,

Today i would like to share you how to change the background color for every form in dynamics ax

Open SysSetupFormRun  Class in AOT, and override its run() with the following code:

public void run()
{;
 super();
 this.design().colorScheme(FormColorScheme::RGB);
 this.design().backgroundColor(WinAPI::RGB2int(255,0,0));
}
 
 
 
 

Tuesday 2 September 2014

Sum of two Numbers using Dialog Class in Ax 2009

Hi ,

Today i would like to share you , how to get the dynamic input value using dialog class

In c, scanf() is used to get the dynamic input value .
Similarly in Ax , Dialog is used to get the dynamic input Value.

For an Example,

I wrote a class to get an input value from users dynamically and print the sum of values as output

Coding:

class Dynamicclass extends RunBase
{
    int FirstNum;
    int SecondNum;
    int SumValue;
   
    DialogGroup diaGrp;
    DialogField diaFld,diaFld2;
    Dialog      dialog;

}

Dialog:

protected Object dialog()
{
    ;

    dialog = super();

    dialog.caption("Enter the valid  Number");

    diaGrp=dialog.addGroup("Number");

    diaFld=dialog.addField(Typeid(Integer)," First Number","Enter the First Number");
    diaFld2=dialog.addField(Typeid(Integer)," Second Number","Enter the second Number");

    return dialog;
   
}

Display Date

void displaydata()
{
    ;
    info(strfmt("First Number =%1",FirstNum));
    info(strfmt("Second Number =%1",SecondNum));
    info(strfmt("Sum of Two Number =%1",SumValue));
}

Get Data:


void getdata(int _firstNum,int _secondNum)
{
    ;
   
    FirstNum    =   _firstNum;
    SecondNum   =   _secondNum;
    SumValue    =   _firstNum+_secondNum;
}

Pack:

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

Run:

void run()
{
    super();
   
    FirstNum = diaFld.value();
    SecondNum = diaFld2.value();
    this.getdata(FirstNum,SecondNum);
    this.displaydata();
}

UnPack:

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

Main:

public static void main(Args args)
{

Dynamicclass obj =new Dynamicclass();

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

}


Output:

Happy Daxing....

Grouping Field Value in Lookup in Ax 2009

Hi ,

Today i would like to share you how to group the field value in Lookup in Ax 2009

Example:
In Customer Table each Customer belongs to at-least one Customer Group.
For an example , Customer Group : India has three customer (Cust-001,cust-002 and cust-003)

Here is a piece of code , how to group the CustGroup Field from CustTable

Coding:
public void lookup()
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;

    SysTableLookup  sysTableLookup = sysTableLookup::newParameters(tableNum(CustTable), this);
    ;

    sysTableLookup.addLookupfield(fieldNum(CustTable, CustGroup));
    queryBuildDataSource = query.addDataSource(tableNum(CustTable));

    queryBuildDataSource.addSortField(fieldnum(CustTable, CustGroup));
    queryBuildDataSource.addOrderByField(fieldnum(CustTable, CustGroup));
    queryBuildDataSource.orderMode(OrderMode::GroupBy);//Used to Group the Field Value

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

Before Using Lookup Method

 After using Lookup Method


Happy Daxing.......