Showing posts with label Enterprise portal. Show all posts
Showing posts with label Enterprise portal. Show all posts

Wednesday, April 22, 2020

Add Custom lookup on EP

The trick is to override datasetLookup() on Dataset > data source > field > methods. You will not find this method in the list of override methods so just create this as new method.
the table which we are using for lookup should be in the Dataset

public void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List list = new List(Types::String);

    Query query = new Query();

    QueryBuildDataSource    queryBuildDataSource;

    QueryBuildRange qbr;

    // Add the table to the query.

    queryBuildDataSource  = query.addDataSource(tableNum(HcmWorker));

    //add the range

    qbr = queryBuildDataSource.addRange( fieldnum(HcmWorker, PersonnelNumber));

   // qbr.value(DirPersonUser::currentWorkerPersonnelNumber());

   // qbr.status(RangeStatus::Locked);

     // Specify the fields to use for the lookup.

    list.addEnd(fieldStr(HcmWorker,PersonnelNumber));

    list.addEnd(fieldStr(HcmWorker,Name()));


     sysDataSetLookup.parmLookupFields(list);

     // Specify the field that is returned from the lookup.

    sysDataSetLookup.parmSelectField('PersonnelNumber');

     // Pass the query to the SysDataSetLookup so that the query is used.

    sysDataSetLookup.parmQuery(query);
 
}

Monday, December 7, 2015

EP : Hide Webmenu Menuitem

 Hide individual menuitem from webmenu

//create OnSetMenuItemProperties event

     protected void AxToolBar_SetMenuItemProperties(object sender,                                                                                                          SetMenuItemPropertiesEventArgs e)
    {
        // Remove the menu item context (query string will be empty)
        if (e.MenuItem.MenuItemAOTName == "EP_XXXXXXXX") //
        {
            e.MenuItem.Hidden = true;
        }
        if (e.MenuItem.MenuItemAOTName == "EP_XXXXXXXX")
        {
            e.MenuItem.Hidden = true;
        }
     }

AX 2012: Access infolog in EP

    Access infolog in EP 

using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;
using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy;

    private ISession AxSession
    {
        get
        {
            AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this);
            return webpart == null ? null : webpart.Session;
        }
    }
    protected void AxGridView1_SelectedIndexChanged(object sender, EventArgs e)
    {    
        Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);
        objInfoLog.add(Proxy.Exception.Warning, "Hello World");
    }

AX 2012: Get Current record in EP

    How do I pass the RecId of the selected record in the list page     to the user control?


Setting the proper properties on the menu item in the list page form will pass the record to the              web user control.
On the menu item just set the NeedsRecord to Yes (not mandatory, but better to have it set in               order for the button to be disabled/enabled), and the DataSource property to the table you want           to have its record passed.

In your user control just add an AxDataSource for a DataSet having the same table, and you will         get your record.

Then just get the record using a standard call in EP as shown (you must also have the                           DataSourceView method implemented):

internal IAxaptaRecordAdapter GetCurrentDatasourceRecord()

{

       IAxaptaRecordAdapter record = null;

       if (this.DataSourceView.DataSetView != null &&

           this.DataSourceView.DataSetView.GetCurrent() != null)

       {

           //setting the record as the current record in the datasource

           record = this.DataSourceView.DataSetView.GetCurrent().GetRecord();

       }

       return record;

   }

AX 2012 : Change Toolbar webmenu by code

 Change Toolbar webmenu by code  in Enterprise Portal

    protected void AxGridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataSetViewRow row;
     
        // Retrieve the current row.
        row = AxDataSource1.GetDataSet().DataSetViews["LoanRequest"].GetCurrent();
     
       // Retrieve the value.
       WorkflowStatus = row.GetFieldValue("WorkFlowStatus").ToString();
        Proxy.Info objInfolog = new Proxy.Info(this.AxSession.AxaptaAdapter);
     
        if (Convert.ToInt32(WorkflowStatus) == 1 || Convert.ToInt32(WorkflowStatus) == 5)
        {
            AxGridView1.AllowDelete = true;
            AxToolBar1.WebMenuName = "LoanRequest";
        }

        else if (Convert.ToInt32(WorkflowStatus) == 2 || Convert.ToInt32(WorkflowStatus) == 3 ||                 Convert.ToInt32(WorkflowStatus) == 4)
        {
            AxGridView1.AllowDelete = false;
            AxToolBar1.WebMenuName = "LoanRequestNotEdit";
        }

        else
        {
            //Do nothing
        }
    }

AX 2012 : Add Custom lookup on EP

Add Custom lookup on EP

The trick is to override datasetLookup() on Dataset > data source > field > methods. You will not find this method in the list of override methods so just create this as new method.
the table which we are using for lookup should be in the Dataset


public void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List list = new List(Types::String);

    Query query = new Query();

    QueryBuildDataSource    queryBuildDataSource;

    QueryBuildRange qbr;

    // Add the table to the query.

    queryBuildDataSource  = query.addDataSource(tableNum(DependentDetails));

    //add the range

    qbr = queryBuildDataSource.addRange( fieldnum(DependentDetails, PersonnelNumber));

   // qbr.value(DirPersonUser::currentWorkerPersonnelNumber());

   // qbr.status(RangeStatus::Locked);

     // Specify the fields to use for the lookup.

    list.addEnd(fieldStr(DependentDetails,DependentId));

    list.addEnd(fieldStr(DependentDetails,Name));


     sysDataSetLookup.parmLookupFields(list);

     // Specify the field that is returned from the lookup.

    sysDataSetLookup.parmSelectField('DependentId');

     // Pass the query to the SysDataSetLookup so that the query is used.

    sysDataSetLookup.parmQuery(query);
 
}

Table browser URL in D365FO

Critical Thinking icon icon by Icons8