Sunday, April 12, 2020

Construct Method in Ax 2012

class ClassTest
{

}




public void show()
{
    info("Atul");
}




public static ClassTest construct()
{
    return new ClassTest();
}




public static void main(Args _args)
{
    ClassTest obj = ClassTest::construct();
    obj.show();
}

Pack UnPack in Dialog Form in Ax 2012

In class declaration write this

//in the start
#define.CurrentVersion(2)



//in the end
#localMacro.CurrentList
        fromDate,
        toDate,
        fromDataAreaId,
        toDataAreaId,
        generalType,
        mainAccounts,
        division
#endMacro







Make this method in the dialog form

container pack()
{
    return [fromDate,toDate,fromDataAreaId,toDataAreaId,generalType,mainAccounts,division];

}


Make this method in the dialog form
boolean unpack(container _packedValues)
{
    [fromDate,toDate,fromDataAreaId,toDataAreaId,generalType,mainAccounts,division] = _packedValues;
    return true;
}

Basic Dialog Form in Ax 2012

class TTC_AY extends RunBase
{
    DialogField fieldName,fieldId;
    TTC_CustomerTable   custTable;
    TTC_CustomerTable2  custTable2;
    TTC_CustID custId;
    TTC_Name custName;
}




protected Object Dialog()
{
    Dialog dialog;
    ;
    dialog = super();
    dialog.caption('Atul Dialog');
    fieldId   =  dialog.addField(extendedTypeStr(TTC_CustID), 'Customer Id');
    fieldName     =  dialog.addField(extendedTypeStr(TTC_Name),'Customer Name');
    return dialog;
}




public boolean getFromDialog()
{
    custId     = fieldId.value();
    custName   = fieldName.value();
    return super();
}




public void run()
{
    while select * from custTable
        where custTable.Name == custName
            && custTable.Id == custId

    if (custTable)
    {
        info( strFmt('%1 -- %2',custTable.Id, custTable.Name));
        custTable2.Id           = custTable.Id;
        custTable2.Name         = custTable.Name;
        custTable2.Email        = custTable.Email;
        custTable2.Phone        = custTable.Phone;
        custTable2.Gender       = custTable.Gender;
        custTable2.CustomerType = custTable.CustomerType;
        custTable2.Balance      = custTable.Balance;
        custTable2.Age          = custTable.Age;
        custTable2.Address      = custTable.Address;
        custtable2.insert();
    }
    else
    {
        error( 'Customer not found!');
    }
}




public static void main(Args _args)
{
    TTC_AY custCreate = new TTC_AY();
    if (custCreate.prompt())
    {
        custCreate.run();
    }
}

Display Methods in Ax 2012

Add the field(Int this case int type) in the form that you want to show(Total in this case) or do the operations on  (display method is used to show the name with id also)

Put the following properties of the field that you added in the Form
datasource   : whatever you want to add
datamethod : name of the method that you will create

now go to the table and create a method (display method is made on table methods)

display public TTC_Dis AmountOrder()
{
    TTC_OrderTable orderTable;

    select sum(Dis) from orderTable;

    return orderTable.Dis;
}

Roles and Security in Ax 2012

System administrator -> common -> users-> users

Create new role for Form display methods
Go to Menuitems and create new menu items

1. Go to security->privilage and create new privilages
go to properties of the privilege and put the name of form and label accordingly
open the privilege -> Entry point
right click on it and create new entry point
name the entry point and put the object type as "MenuItemDisplay"
and put object name as required(i.e the Display MenuItem that is required)
and put access level as "Delete"

2. Go to security->duty and create new duty
go to properties of the duty and put the name of the duty and label accordingly
go to security->duties->DutyThatYouCreated->privileges
right click on it and create new privilege
go to properties and put the name of the privilege

3. Go to Security->Roles
create new role and put the name and label it as you require
open the role and go to duties create new duty and name it accordingly
now go to privileges and create new privilege and name it accordingly
now save it
now you can see your role for assigning to users

NOTE:-
ye grouping hai basically,menuitem ki grouping kar ke privilege banate hai
jaise 5 privilege bana liye,uss mei se ek duty bna li usmein 3 ko privilege de diya
phir dusra duty bna liya uss ko 5 ka privilege de diya
phir roles assign hote hai user ko

Monday, April 6, 2020

Form Datasource Methods in Ax 2012


Active : The user selects a new record.Retrieves data from joined datasource when a user moves to a new record.

Create : The user creates a new record in the datasource.If you use this method to specify field valuues,the new value are saved to the database when you leave the form.

Delete : the user deletes a record in the datasource.Deletes the current reord from the datasource.

ExecuteQuery : The form is opened for data display.Executes the datasource query and displays the retrieved records.

Filter : The user starts one of the filter commands on the form shortcut menu.Filter records in the datasource.

FindRecord : Activated by the find value method.Finds the specified record in the database and makes it the current one.

InIt : The form is opened.Creates a datasource query based on the datasource properties.

InItValue : A new record is created.The purpose is to fill in initial values in the record.Initializes field values in a new record.If you use this method to specify field values,the new values are not automatically saved to the database when you leave the form.To specify values that you want to save when you leave the form,use the created method.

LinkActive : The user selects a new record in a form that has a datasourcelinked to another datasource.Calls the FormDataSource.executeQuery method on data sources that are linked to the current data source.

Refresh : Not sgtarted by the system.Updates the form by refreshing the view of all records in the datasource.WILL NOT REREAD THE RECORD FROM THE DATASOURCE.IT BASICALLY JUST REFRESHES THE SCREEN WITH WHATEVER IS STORED IN THE FORM FROM THE CACHE.

Reread : Not started by the system.Rereads the current record from the datasource.WILL ONLY REREAD THE CURRENT RECORD FROM THE DATABASE SO YOU SHOULD NOT USE IT TO REFRESH THE FORM DATA IF YOU HAVE ADDED/REMOVED RECORDS.

Research : Not started by the system.Refreshes the database search defined by the query , specified by the FormDataSource.init method.WILL RETURN THE EXISTING FORM QUERY AGAINST THE DATASOURCE,THEREFORE UPDATING THE LIST WITH NEW /REMOVED RECORDS AS WELL AS UPDATING EXISTING ONES.THIS WILL HONOUR ANY EXISTING FILTERS AND SORTING ON THE FORM.

SelectionChanged() : The user selects or unselects one or morerecords in the datasource.Enables youo to change the property values of control when the selected record changes.

ValidateWrite() : A new or updated record is to be written determines whether data is valid and ready to be written.

Write() : The user inserts a new record or updates an existing one.Calls the FormDataSource.validateWrite method and manages the database write operation.

Form Control Methods in Ax 2012


Validate : The user exists a control after entering data.

Lookup : The user uses the lookup facility.

Modified : The user exits an edit field after changing it.The user changes a value in a checkbox,combobox,listbox or radio button control.The super call manages the table update.

Form Methods in Ax 2012


Activate : When a form receives focus.Returns boolean data type that specifies whether a form has focus.

CanClose : When aform is closed.specifies whether you can close the form.The call to the super in the method checks whether closing the form is a valid action.

Closed : The form is closed.use this method to check whether the form has been closed.

Close : The form is closed.the call to the super in this method closes the form window,manages database updates and sets the closed method to true.

CloseCancel : Use this method to check whether the form has been closed by a cancel action.the method is set to true if the form is closed by a cancel action.

CloseOk : The user presses an ok button.specifies whether the form wasa closed by clicking the ok button.the call to the super method sets the boolean flag closedok and calls the close method.

InIt : The form is opened.use the method to initialize a form.the init method I started immediately after the new method and creates the run time image of the form.you must call the super method if you override this methpd and you should add your code before the super call.

Run : The form is opened.Call the run method immediately after the init method.The call to the super method makes the form window appear on the screen and performs a database search for the data to be displayed in the form.

Method Flow                                     Init->Run

How to create Inventory Ax 2012

How to create Inventory

Process Inventory Adjustment -> New -> Lines -> Validate -> Post

1.New:
                           Form name                   : InventJournalTable
                           Table(Datasource) : InventJournalTable

2.Lines:
                           Form name                   : InventJournalLossProfit
                           Table(Datasource) : InventJournalTrans


How to create a Sales order Ax 2012

How to create a SO(Sales Order)

Process SO -> PickList -> PickingListRegistration -> PackingList -> Invoice -> Post

1.SO:
                           Form name         : SalesTable
                           Table(Datasource) : SalesTable,
                                                                        SalesLine
                           Relation         :
                           SalesLine.SalesId == SalesTable.SalesId
                           Class                 : SalesTableForm

2.PickingList:
                           Form name         : WMSPickingRoutesJournal
                           Table(Datasource) : WMSPickingRoute,
                                            WMSOrderTrans
                           Relation         :       
                           WMSOrderTrans.routeId == WMSPickingRoute.pickingRouteID
                           Class                 : SalesPickingListJournalCreate

3.PickingListRegistration:
                           Form name                  : WMSPickingRegistration
                           Table(Datasource) : WMSPickingRoute,
                                                                WMSOrderTrans
                           Relation         :         
                           WMSOrderTrans.routeId == WMSPickingRoute.pickingRouteID
                           Class                 : No Classs was hit by debugger

4.PackingSlip:
                           Form name         : CustPackingSlipJournal
                           Table(Datasource) : CustPackingSlipJour,
                                                    CustPackingSlipTrans
                           Relation           
                                  CustPackingSlipTrans.SalesId == CustPackingSlipJour.SalesId
                                  CustPackingSlipTrans.PackingSlipId == CustPackingSlipJour. PackingSlipId
                                  CustPackingSlipTrans.DeliveryDate == CustPackingSlipJour.DeliveryDate
                           Class                         : SalesPackingSlipJournalCreate

5.Invoice:
                           Form name         : CustInvoiceJournal
                           Table(Datasource) : CustInvoiceJour,
                                            CustInvoiceTrans
                           Relation         :
                           CustInvoiceTrans.SalesId         == CustInvoiceJour.SalesId
                           CustInvoiceTrans.InvoiceId      == CustInvoiceJour.InvoiceId
                           CustInvoiceTrans.InvoiceDate  == CustInvoiceJour.InvoiceDate
         CustInvoiceTrans.numberSequenceGroup  == CustInvoiceJour.numberSequenceGroup
                           Class                :  SalesInvoiceJournalCreateBase

How to create a Purchase order Ax 2012

How to create a PO(Purchase Order) 

Process PO -> Confirm -> Receive -> Invoice -> Post

1.PO Main Form:
                           Form name         :       PurchTable
                           Table(Datasource) : PurchTable,
                                                                        PurchLine
                           Relation         :
                           PurchLine.PurchId == PurchTable.PurchId
                           Class                 : PurchCreateOrderForm

2.Create PO Form:
                           Form name         : PurchCreateOrder
                           Table(Datasource) : PurchTable,
                                                                        PurchTable_W
                           Class                 : PurchCreateOrderForm

3.Purchase Order Confirmations:
                           Form name         : VendPurchOrderJournal
                           Table(Datasource) : VendPurchOrderJour
                           Class                 : PurchPurchOrderJournalCreate

4.Receive(Receipt list):
                           Form name         : VendReceiptsListJournal
                           Table(Datasource) : VendReceiptsListJour,
                                            VendReceiptsListTrans
                           Relation         :
        VendReceiptsListTrans.PurchId                 == VendReceiptsListJour.PurchId
        VendReceiptsListTrans.ReceiptsListId      == VendReceiptsListJour. ReceiptsListId
        VendReceiptsListTrans. ReceiptsListDate == VendReceiptsListJour. ReceiptsListDate

5.Receive(Product receipt):
                           Form name         :   VendPackingSlipJournal
                           Table(Datasource) : VendPackingSlipJour
                           Class                 : FormLetterVersionableJournalCreate,
                                                    FormLetterJournalCreate

6.Invoice:
                           Form name         : VendInvoiceJournal
                           Table(Datasource) : VendInvoiceJour,
                                               VendInvoiceTrans
                           Relation         :
                VendInvoiceTrans.PurchId                 == VendInvoiceJour.PurchId
        VendInvoiceTrans.InvoiceId              == VendInvoiceJour. InvoiceId
        VendInvoiceTrans.InvoiceDate         == VendInvoiceJour. InvoiceDate
        VendInvoiceTrans.numberSequenceGroup == VendInvoiceJour. numberSequenceGroup
        VendInvoiceTrans.InternalInvoiceId == VendInvoiceJour. InternalInvoiceId
                           Class                : PurchInvoiceJournalCreate,
                                              FormLetterJournalCreate