Thursday 18 September 2014

Workflow Process methods in ax 2012

Table level method :
boolean canSubmitToWorkflow(str _workflowType = '')
{
    boolean     canSubmit = false;
    ;
    if (!this.SubDealerApprovalStatus  == SubDealerApprovalStatus::NotSubmitted)
    {
        return false;
    }
    return true;
}

Public static void setWorkflowState (RecId _RecId,
                             SPL_SalesMarketStatus _SPL_SalesMarketStatus)
{
    smmBusRelTable            smmBusRelTable,smmBusRelTableloc;

    Ttsbegin;

   select  smmBusRelTableloc where smmBusRelTableloc.RecId == _RecId;
   select forUpdate  smmBusRelTable where smmBusRelTable.RecId == smmBusRelTableloc.RecId;
   smmBusRelTable.SPL_SalesMarketStatus= _SPL_SalesMarketStatus;

    Switch (_SPL_SalesMarketStatus)
    {

        Case SPL_SalesMarketStatus::Notsubmitted:
             smmBusRelTable.SPL_SalesMarketStatus = SPL_SalesMarketStatus::Notsubmitted;
             Break;

        Case SPL_SalesMarketStatus::Submitted:
            smmBusRelTable.SPL_SalesMarketStatus = SPL_SalesMarketStatus::Submitted;
             Break;

        Case SPL_SalesMarketStatus::Approved:
            smmBusRelTable.SPL_SalesMarketStatus = SPL_SalesMarketStatus::Approved;
             Break;

        case SPL_SalesMarketStatus::Rejected:
            smmBusRelTable.SPL_SalesMarketStatus = SPL_SalesMarketStatus::Rejected;
             Break;


        Case SPL_SalesMarketStatus::ChangeRequested:
             smmBusRelTable.SPL_SalesMarketStatus = SPL_SalesMarketStatus::ChangeRequested;
             Break;

        Default:
           Break;
    }
   smmBusRelTable.update();
    Ttscommit;
}

_____________________
Class methods:
class SubDealApprovalEventHandler implements    WorkflowElementCanceledEventHandler,     WorkflowElemChangeRequestedEventHandler,
                                                        WorkflowElementCompletedEventHandler, WorkflowElementReturnedEventHandler,
                                                        WorkflowElementStartedEventHandler, WorkflowElementDeniedEventHandler,
                                                        WorkflowWorkItemsCreatedEventHandler
{
}
public void canceled(WorkflowElementEventArgs _workflowElementEventArgs)
{
     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::canceled;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs)
{
     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::ChangeRequested;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void completed(WorkflowElementEventArgs _workflowElementEventArgs)
{
     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Approved;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void denied(WorkflowElementEventArgs _workflowElementEventArgs)
{

     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Rejected;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void returned(WorkflowElementEventArgs _workflowElementEventArgs)
{
     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Rejected;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void started(WorkflowElementEventArgs _workflowElementEventArgs)
{
     smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowElementEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Submitted;
        smmBusRelTable.update();
    }
    ttsCommit;
}
___________________
class SubDealerApprDocument extends WorkflowDocument
{
}
public queryName getQueryName()
{
    return querystr(SubDealerApproval);
}
______________
class SubDealerApprEventHandler implements    WorkflowCanceledEventHandler,  WorkflowCompletedEventHandler,
                                                        WorkflowStartedEventHandler
{
}
public void canceled(WorkflowEventArgs _workflowEventArgs)
{

    smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Rejected;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void completed(WorkflowEventArgs _workflowEventArgs)
{
    smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Approved;
        smmBusRelTable.update();
    }
    ttsCommit;
}
public void started(WorkflowEventArgs _workflowEventArgs)
{
    smmBusRelTable        smmBusRelTable;
    ttsBegin;
    select forupdate smmBusRelTable where smmBusRelTable.RecId ==
        _workflowEventArgs.parmWorkflowContext().parmRecId();
    if (smmBusRelTable.recid)
    {
        smmBusRelTable.SubDealerApprovalStatus = SubDealerApprovalStatus::Submitted;
        smmBusRelTable.update();
    }
    ttsCommit;
}
_________
public class SubDealerApprSubmitManager
{
}
public static void main(Args args)
{
    SubDealerApprSubmitManager   Submitmanager =new  SubDealerApprSubmitManager();
    ;
    Submitmanager.submit(args);
}
void submit(Args args)
{
    // Variable declaration.
    recId recId = args.record().RecId;
    WorkflowCorrelationId workflowCorrelationId;
    // Hardcoded type name
    WorkflowTypeName workflowTypeName =workflowtypestr(SubDealerAppr);
    // Initial note is the information that users enter    when they
    // submit the document for workflow.
    WorkflowComment note ="";
    WorkflowSubmitDialog workflowSubmitDialog;
    smmBusRelTable smmBusRelTablelocal;
    // Opens the submit to workflow dialog.
    workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
    workflowSubmitDialog.run();
    if (workflowSubmitDialog.parmIsClosedOK())
    {
        recId = args.record().RecId;
        smmBusRelTablelocal = args.record();
        if(!smmBusRelTablelocal.CustGroup)
        {
            throw error("Please select the customer group");
        }
        // Get comments from the submit to workflow dialog.
        note = workflowSubmitDialog.parmWorkflowComment();
        try
        {
            ttsbegin;
                workflowCorrelationId = Workflow::activateFromWorkflowType(workflowTypeName,recId,note,NoYes::No);
                smmBusRelTablelocal.SubDealerApprovalStatus = SubDealerApprovalStatus::Submitted;
                smmBusRelTablelocal.update();
                // Send an Infolog message.
               // info("Submitted to workflow.");
            ttscommit;
        }
        catch(exception::Error)
        {
            info("Error on workflow activation.");
        }
    }
    args.caller().updateWorkFlowControls();
}
____________________________________
Public class SPL_SalesMarApprovalResubmitActionMgr
{
    smmBusRelTable            smmBusRelTable;

    RecId                       vendtableid;
    WorkflowVersionTable        workflowVersionTable;
    WorkflowComment             workflowComment;
    Boolean                     submit;
    WorkflowWorkItemTable       workflowWorkItemTable;
    UserId                      userId;
    MenuItemName                menuItemName;
    EPWorkflowControlContext    workflowControlContext;
    WorkflowTypeName            workflowTemplateName;
}

Public Boolean dialogOk ()
{
    WorkflowSubmitDialog            workflowSubmitDialog;
    WorkflowWorkItemActionDialog    workflowWorkItemActionDialog;
    Boolean                         ok;


     If (menuItemName == menuitemActionStr(SPL_SalesMarApprovalResubmitMenuItem))
    {
        WorkflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct(
                                            WorkflowWorkItemTable,
                                            WorkflowWorkItemActionType::Resubmit,
                                            New MenuFunction (menuitemActionStr (SPL_SalesMarApprovalResubmitMenuItem), MenuItemType::Action));

        workflowWorkItemActionDialog.run ();
        this.parmWorkflowComment(workflowWorkItemActionDialog.parmWorkflowComment ());
        Ok = workflowWorkItemActionDialog.parmIsClosedOK();
        UserId = workflowWorkItemActionDialog.parmTargetUser();
    }
    if(Ok == true)
    {
        Ok = true;
    }
    else
    {
        Ok = false;
    }


    Return ok;
}

Public void init (RecId                       _documentRecordId,
    MenuItemName                _menuItemName,
    WorkflowVersionTable        _workflowVersionTable,
    WorkflowWorkItemTable       _workflowWorkItemTable,
    EPWorkflowControlContext    _workflowControlContext)
{
    If (_documentRecordId)
    {
        this.parmvendtableid(_documentRecordId);
        this.parmSubmit(_menuItemName == menuitemActionStr(SPL_SalesMarketApprSubmitMenuItem));
        this.parmMenuItemName(_menuItemName);

        If (_workflowControlContext)
        {
            this.parmWorkflowControlContext(_workflowControlContext);
            this.parmWorkflowWorkItemtable(_workflowControlContext.getActiveWorkflowWorkItem());
            this.parmWorkflowComment(_workflowControlContext.getWorkflowComment());
            this.parmWorkflowTemplateName(_workflowControlContext.getActiveWorkflowConfiguration().workflowTable().TemplateName);
        }
        Else
        {
            this.parmWorkflowVersionTable(_workflowVersionTable);
            this.parmWorkflowWorkItemtable(_workflowWorkItemTable);
            this.parmWorkflowTemplateName(this.parmWorkflowVersionTable().workflowTable().TemplateName);
        }
    }
}

Public menuItemName parmMenuItemName (menuItemName _menuItemName = menuItemName)
{
    MenuItemName = _menuItemName;
    Return menuItemName;
}


Public Boolean parmSubmit (Boolean _submit = submit)
{
    Submit = _submit;
    Return submit;
}

Public RecId parmvendtableid (RecId _vendtableid = VendTableid)
{
    VendTableid = _vendtableid;

    Return vendtableid;
}

Public WorkflowComment parmWorkflowComment (WorkflowComment _workflowComment = workflowComment)
{
    WorkflowComment = _workflowComment;
    Return workflowComment;
}

Public EPWorkflowControlContext parmWorkflowControlContext (EPWorkflowControlContext _workflowControlContext = workflowControlContext)
{
    WorkflowControlContext = _workflowControlContext;
    Return workflowControlContext;
}

Public workflowTypeName parmWorkflowTemplateName (workflowTypeName _workflowTemplateName = workflowTemplateName)
{
    WorkflowTemplateName = _workflowTemplateName;
    Return workflowTemplateName;
}

Public WorkflowVersionTable parmWorkflowVersionTable (WorkflowVersionTable _workflowVersionTable = workflowVersionTable)
{
    workflowVersionTable = _workflowVersionTable;
    Return workflowVersionTable;
}

Public WorkflowWorkItemTable parmWorkflowWorkItemtable (WorkflowWorkItemTable _workflowWorkItemTable = workflowWorkItemTable)
{
    ;
    WorkflowWorkItemTable = _workflowWorkItemTable;

    Return workflowWorkItemTable;
}

Public void reSubmit()
{
WorkflowWorkItemActionManager::dispatchWorkItemAction (WorkflowWorkItemTable,WorkflowComment, UserId, WorkflowWorkItemActionType::Resubmit, MenuItemName,
 MenuItemName == webActionItemStr (EPCustFreeInvoiceReSubmit));

    smmBusRelTable::setWorkflowState(vendtableid, SPL_SalesMarketStatus::Submitted);
}

Public void submit()
{
    NoYes               activatingFromWeb;

    ActivatingFromWeb = this.parmWorkflowControlContext() == null? NoYes::No: NoYes::Yes;


    Workflow::activateFromWorkflowType(this.parmWorkflowTemplateName(), vendtableid,this.parmWorkflowComment(), ActivatingFromWeb);

     smmBusRelTable::setWorkflowState(vendtableid, SPL_SalesMarketStatus::Submitted);
}

Public static SPL_SalesMarApprovalResubmitActionMgr construct()
{
    Return new SPL_SalesMarApprovalResubmitActionMgr();
}

Public static void main(Args _args)
{
    SPL_SalesMarApprovalResubmitActionMgr SPL_SalesMarApprovalResubmitActionMgr;
    smmBusRelTable        smmBusRelTable;
    FormDataSource          vendtableDataSource;

    smmBusRelTable = _args.Record();
    VendtableDataSource = smmBusRelTable.DataSource();

    SPL_SalesMarApprovalResubmitActionMgr = SPL_SalesMarApprovalResubmitActionMgr::construct();

    If (_args.menuItemName() == menuitemActionStr(SPL_SalesMarApprovalResubmitMenuItem))
    {
        SPL_SalesMarApprovalResubmitActionMgr.init(smmBusRelTable.RecId, _args.menuItemName(),
            _args.caller().getActiveWorkflowConfiguration (),
            _args.caller().getActiveWorkflowWorkItem (),
            Null);
    }
    Else
    {
        SPL_SalesMarApprovalResubmitActionMgr.init(
            smmBusRelTable.RecId,
            _args.menuItemName (),
            Null,
            Null,
            _args.caller ());
    }

    If (SPL_SalesMarApprovalResubmitActionMgr.dialogOk())
    {
        If (SPL_SalesMarApprovalResubmitActionMgr.parmSubmit())
        {
            SPL_SalesMarApprovalResubmitActionMgr.submit();
        }
        Else
        {
            SPL_SalesMarApprovalResubmitActionMgr.reSubmit();
        }

        If (vendtableDataSource)
        {
            vendtableDataSource.research(true);
            vendtableDataSource.refresh();
        }

        If (_args.menuItemName() == menuitemActionStr(SPL_SalesMarApprovalResubmitMenuItem))
        {
            _args.caller().updateWorkflowControls();
        }
    }
}


Tuesday 16 September 2014

Security Framework– Create Policies in AX 2012

This is really interesting and I thoroughly enjoyed learning Policies and implementing them.
The extensible data security framework is a new feature in Microsoft Dynamics AX 2012 that enables developers and administrators to secure data in shared tables such that users have access to only the part of the table that is allowed by the enforced policy. This feature can be used in conjunction with role-based security (also supported in Microsoft Dynamics AX 2012) to provide more comprehensive security than was possible in the past. [MS Help]
Extensible data security is an evolution of the record-level security (RLS) that was available in earlier versions of Microsoft Dynamics AX. Extensible data security policies, when deployed, are enforced, regardless of whether data is being accessed through the Microsoft Dynamics AX rich client forms, Enterprise Portal webpages, SSRS reports, or .NET Services [MS help]
Let me walk through with a simple example:
Requirement is to show a particular user only those Bank accounts that belongs to the Bank group “BankCNY
Below are the Bank accounts that are available in my system. By using policy framework on roles , I can restrict user to view only bank accounts that belong to Bank group “BankCNY”
image
First of all , where are these policies in AX? They are actually in the AOT >> Security >> Policies
image 
Before we create policies, we need to create a query to use it in policies. Remember, try to optimize the queries to the best otherwise it might lead to performance issues.
To keep it very simple, Create a Query by name SR_BankAccountTable by adding data source[PrimaryTable] as “BankAccountTable” and add a range on BankGroupId field and set it to “BankCNY” as shown below

image
Now let us create a new Role by name SR_BankController as shown below
Go to AOT >> Security >> Roles >> New Role
image
Set the following properties of the newly created role by right clicking and going to properties
image
Now lets create duties for this role: In this example I will create one simple duty called “SR_BankAccountsMaintain
Go to AOT >> Security >> Duties >> Right click >> New Duty
image
Set the following properties for the newly create duty. Name it as “SR_BankAccountsMaintain” and provide label and description as shown below

image
Now, let us create a new privilege and add entry points [Menu Items] to it to provide only access to the user
Go to AOT >> Security >> Privilege >> New Privilege.
image
Name the privilege as “SR_BankAccountTableMaintain” and set the label and Description as shown below
image
Now drag and drop some menu items on to Entry points from AOT >> Menu Items >> Display as shown below
image
Now add this newly created privilege  “SR_BankAccountTableMaintain” to the duty “SR_BankAccountMaintain” which we have created.
image
Then, add SR_BankAccountsMaintain duty to the Role SR_BankController
image
Now, let us create a new Policy by name “SR_BankAccountPolicy” and set the properties as shown below
image
Set the below properties
image
In the above screen, Select the context type as “RoleName“ and the role “SR_BankController” and select the query as ”SR_BankAccountTable
PrimaryTable : should always be the first data source Table which you have added in the query. So, select BankAccountTable
constrained table is the table or tables in a given security policy from which data is filtered or secured, based on the associated policy query. For example, in a policy that secures all sales orders based on the customer group, the Sales Order table would be the constrained table. Constrained tables are always explicitly related to the primary table in the policy [MS Help]
Context [MS help]
A policy context is a piece of information that controls the circumstances under which a given policy is considered to be applicable. If this context is not set, then the policy, even if enabled, is not enforced.
Contexts can be of two types: role contexts, and application contexts. A role context enables policy application based on the role or roles to which the user has been assigned. An application context enables policy application based on information set by the application
we are almost done, we need to add this role= to some user and verify whether he is able to see only Bank accounts that belongs to BankCNY group
Go to System Administration >> Users >> select any user >> Click on Assign roles.
Select “Bank Accounts controller”  and click on Ok Button.
image
Now , let us log in with the user credentials for which we have assigned the new Role and verify the Bank accounts.
As you see, the user can only see the Bank accounts which belong to “BankCNY” group.
image
That’s it for now.

Disconnected from the AOS in AX 2012 and Visual Studio .Net

http://eprogrammers.blogspot.in/2014/02/how-to-resolve-error-disconnected-from.html

When you want to connect your visual Studio to a spesific AOS, you have to follow this steps:
1°: Change the path in your Shortcut in the AOS server
* Create the BC Ax configuration file and refresh the configuration
*  Create an AX client  shortcut (.axc)
=> Result: you have : "C:\AX2012_RTM_DVP.axc"
* Create a visual studio shortcut  and modifiy the shortcut path to add this command inside :
=> Result: you have cmd command and run this command "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"    /AxConfig "C:\AX2012_RTM_DVP.axc"

2° Set the AX client Active Configuration to your AOS
Just use the Administrative Tool > AX 2012 Configuration to do it
 
 
 

Record Level Security in Ax 2012

Today we are going to discuss Record Level Security in Ax 2012.  

After that press Cntrl+N to create a record , the wizard will be opened. Click all the tables which you want to create record level security and finish it.

There will be a query button which you can add ranges to it.


This RLS is restricted to particular company only and the RLS is limited to particular group only . 

Note :: To arrange restrictions on the particular group use SysQueryRangeUtil class. 


(SysQueryRangeUtil::currentinvntsite());

Thursday 4 September 2014

Ax 2012 Model-driven list pages

list pages:-
The following list describes the sequence of high-level steps that you can follow to create a model-driven list page:
1. Start the Development Workspace.
2. Create a new Form in the AOT, and set the FormTemplate property to ListPage. This will au-tomatically add some design elements, such as the filter, grid, and Action Pane.
3. Set the query on the form to get the data to be displayed in the form.
4. Set the DataSource on the grid to the required data view.
5. Add the fields to display in the grid.
6. Create and add an Action Pane and info parts, if required. Ideally, you should create one info part to be displayed in the Preview Pane (below the grid), and one or more info parts, form parts, and cue groups to be displayed in the FactBox area (to the right of the grid). The Pre-view Pane should display extended information about the selected record, and the FactBoxes should display related information. To link these parts to the list page, you will need to create the corresponding display menu items.
7. Create a display menu item that points to the form. Right-click the menu item, and then click Deploy to EP.
8. When prompted, select the module that you want to deploy the page to.
This will automatically create a SharePoint Web Part page for the list page for Enterprise Por-tal. It will also create a URL web menu item and import the corresponding page definition into the AOT.
9. Set the HyperLinkMenuItem property on the first field in the grid to a display menu item cor-responding to a details page. This will render links in the first column that can be used to open up the record by using a linked details page. (Note See the next section for information about how to create a details page).
For more information about list page development, see List Page Reference on MSDN.
To achieve more control over how your model-driven list page behaves, you can specify a custom interaction class by using the InteractionClass property on the form. This is discussed in more detail in later sections.

Details pages:-
A details page in Enterprise Portal displays detailed information about a specific selected record.
The following list describes the high-level steps that you can follow to create a details page:
1. Start Visual Studio, and use the EP Web Application Project template (found under the Mi-crosoft Dynamics AX category) to create a new project.
2. Add a new item to the project by using the EP User Control with Form template (found under the Microsoft Dynamics AX category). This will also automatically add the control to the AOT.
3. Switch to design view, select the AxDataSource control, and set the DataSet name.
4. Select the AxForm control, and ensure that DataSourceID is set to the AxDataSource.
5. Set the DataMember and DataKeyNames properties on the form as appropriate.
6. If required, change the default mode of the form to Edit or Insert (it is ReadOnly by default).
7. To auto generate the Save and Close buttons:
a. In ReadOnly mode: Set AutoGenerateCancelButton to true.
b. In Edit mode: Set AutoGenerateEditButton to true.
c. In Insert mode: Set AutoGenerateInsertButton to true.
d. Select an AxGroup control, and ensure that the FormID property is set.
8. Click the Edit Fields link, and add the required fields to the AxGroup control.
9. Compile the EP Web Application by using the Build menu. Ensure that there are no errors. This will also automatically deploy the control to the SharePoint directory.
10. Start the Development Workspace, and navigate to \Web\Web Content\Managed.
87
11. Right-click the Managed item that maps to the web user control that you have created, and click Deploy to EP.

12. When prompted, select the module to deploy the page to.
This will automatically create a SharePoint Web Part page for Enterprise Portal and put your web user control on the page by using the User Control Web Part. It will also create a URL web menu item and import the corresponding Page Definition into the AOT.
13. Select the URL web menu item that you created for the page, and set the WindowMode prop-erty to Modal. This will cause the details page to open in a modal window.
14. Create a new Display Menu Item, and set the WebMenuItemName property to the URL Web Menu Item that is linked to the details page.
15. Use this Display Menu Item to link to the details page from the list page grid, as described in the “Model-drive list pages” section.
Enterprise Portal has also made it very easy to implement a variety of interaction patterns by using modal win-dows. This is discussed in more detail in later sections.

List page interaction classes
initialized Called after the list page has been initialized.
 initializing Called when the list page is initializing.
 selectionChanged Called when the list page selection changes.
 setButtonEnabled Enables or disables buttons. This method is called from the selection-Changed method.
 setButtonVisibility Displays or hides buttons. This method is called when the form opens.
 setCaption Changes the form caption. This method is called when the form opens.
 setGridFieldVisibility Shows or hides grid fields. This method is called when the form opens.
 setListPageType Used to identify the type of list page when you work with secondary list pag-es.
 setModeledQueryName Replaces the query. This method is called when the form opens.
http://dynamicsax.contoso.com/sites/DynamicsAx/Enterprise%20Portal/?RUNONCLIENT=1&IsDlg=1.
https://dynamicsaxgyan.wordpress.com/2012/01/06/one-click-deploy-to-ep-ax-client-forms-using-menu-items-in-dynamics-ax-2012/

Enterprise Portal 2009:-
Creating a dataset
First of all, let's have a look at how we create datasets in AX that we will later use by
the .NET controls.
The datasets defined in the AOT are used by the AxDatasource control in ASP.NET
to fetch data from AX and send data back again when updated in a data binding
enabled ASP.NET control.
A dataset can be considered a replacement of the Datasource node in the web forms
and web reports. As web forms and web reports will eventually be phased out from
AX, we should now use a dataset to connect the fields in our .NET forms to fields in
AX tables.
1. To create a dataset, open the AOT and browse to Data Sets. Right-click on Data Sets and select New Data Set.
2. Right-click on the new dataset and select Properties to show the properties window. Then change the Name property to RentalDataSet.
3. Go to the Data Sources node under the dataset and add a new data source by right-clicking on the Data Sources node and selecting New Data Source.Open the properties window for the new data source and change the table and name property to RentalTable.

Creating a new Visual Studio project
Before you start creating a Visual Studio project, make sure that the Enterprise Portal
development tools are installed on the same computer as Visual Studio.
1. To create a new project in Visual Studio, open Visual Studio and select File | New | Web Site.
2. In the form that opens, select Dynamic Data Web Site, change the name, and click on the OK button.

You are now good to go with a new web site project in Visual Studio. You will use this project for the rest of the examples in this chapter.

Creating a grid
Follow these steps to create a grid control in ASP.NET that retrieves data:
1. Right-click on the website in the Solution Explorer in Visual Studio and select Add New Item.
2. Select Dynamics AX User Control and give it a name that makes sense.
3. Now that the control has been created, right-click on it in the Solution Explorer and select Add to AOT.
4. When that is done, the control is saved in the AOT under Web | Web files |Web controls. This step has to be performed in order to use the user control from the SharePoint page.
5. Open the user control and add an AxDataSource control to the user control simply by dragging it into the design view.
6. Click on the arrow to the right-hand side of the AxDataSource control in the design view and change the DataSet Name property to the dataset you just created in AX.
7. You can also do this by right-clicking on the control and selecting Properties to open the properties window. From here you can also change the rest of the parameters, as shown in the next screenshot.
8. Now, go to the toolbox and drag the AxGridView control onto the design view.
9. Click on the arrow to the right of the control to select the most important properties.
10. The next thing to do is to set the Data Source property to the data source that you have just created.
11. Also, if you would like the users to be able to edit or delete records from the grid, you have to check the Enable Editing or Enable Deleting checkboxes.
12. You can't insert records from a grid by using the AxGridView control.Instead you can add action in a toolbox that opens a tunnel or wizard that lets the user create a new record.
13. Next, click on the Edit Columns link to select the columns from the data source that you want to use in the grid.
14. Available display and edit methods are also shown in the list of fields. Select all the fields in the list except the dataAreaId, TableId, and RecId. Then click on the OK button.

The grid is now ready to be used by a web part page.

Creating a new Web Part page
To create a web part page, make sure you have installed and set up Enterprise Portal.
1. Start by opening the Enterprise Portal in a web browser. Click on the Site Actions button in the upper-right corner, and then click on the Create button, as shown in the next screenshot.
2. In the page that opens, click on the Web Part page under the Web Pages group.
3. The next page will ask you for the name of the page, what template you would like to use, and in which document library you would like the page to be stored in.
Name the page CarRental and select the template called Header,Left Column, Body and store the page in the Enterprise Portal document library.
4. The page will now open in edit mode where you can add web parts.Add a new web part by clicking on the Add a Web Part button under the body section.
5. In the window that opens, find and select the Dynamics User Control Web Part and click on the Add button.
6. When you are back in edit mode, click on the Edit button in the new web part and select Modify Shared Web Part.
7. In the property window, you will find the user control you created in the list of Managed content item as shown in the next screenshot:
8. Once you have selected it, scroll down to the bottom and click on the OK button. Back in the edit mode, you can click on the Exit edit mode link in the top-right corner to see what the page looks like.
The web part page should now look something like :
You
You have now created a SharePoint page with a grid that lists records from the
RentalTable where users can edit and delete records.
The next thing to do is enable users to enter new records as well. From a user point
of view, I would say that I should have been able to do this directly from the grid,
but since that won't work we can create a tunnel (also known as a wizard) to
achieve this.