Tuesday, 4 September 2018



Enable/Disable Button in listpage in D365



here i have added 4 button in salesQuotationlistpage.
now i need to enable/disable button according status. so i have Extensionof  of class
SalesQuotationListPageInteraction and modify setButtonEnabled mathod by Chain of Command







//list page button enable and diable in listpage interation class
[ExtensionOf(classStr(SalesQuotationListPageInteraction))]
final class SQTableinimathod_Extension
{
    protected void setButtonEnabled()
    {
      
        SalesQuotationTable SalesQuotationTable;
        CustQuotationJour   CustQuotationJour;
        CustQuotationConfirmJour  CustQuotationConfirmJour;
     


        next setButtonEnabled();
        SalesQuotationTable SalesQuotationTable1 = this.listPage().activeRecord(queryDataSourceStr(SalesQuotationListPage, SalesQuotationTable));
        select CustQuotationJour
            where CustQuotationJour.QuotationId == SalesQuotationTable1.QuotationId;
        if(CustQuotationJour)
        {
            this.listPage().actionPaneControlEnabled(formControlStr(SalesQuotationListPage, Aks_QuotationJournals), true);
        }
        else
        {
            this.listPage().actionPaneControlEnabled(formControlStr(SalesQuotationListPage, Aks_QuotationJournals), false);
        }

        if(SalesQuotationTable1.QuotationStatus == SalesQuotationStatus::Confirmed)
        {
            this.listPage().actionPaneControlEnabled(formControlStr(SalesQuotationListPage, Aks_ConfirmationJournal), true);
        
           
        }
        else
        {
            this.listPage().actionPaneControlEnabled(formControlStr(SalesQuotationListPage, Aks_ConfirmationJournal), false);
          
        }
     

        
    }





Thanks
Akshay



    


Button Enable/Disable in D365



            There are 4 button added in sales table form
This will enable / disable according status.
Solution : sales table form-> event-> initialized (post event)->copy event handler
Create class


class Aks_ManuItemHide
{
   

  

   

  // button enable and disable in sales table form
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormEventHandler(formStr(SalesTable), FormEventType::Initialized)]
    public static void SalesTable_OnInitialized(xFormRun sender, FormEventArgs e)
    {
        Common common1 = sender.args().record();
        SalesTable SalesTable;
        CustConfirmJour   CustConfirmJour;
        WMSPickingRoute    WMSPickingRoute;
        CustPackingSlipJour  CustPackingSlipJour;
        CustInvoiceJour     CustInvoiceJour;
           
        SalesTable = common1;
     
        FormControl    God_buttonJournalConfirmation           = sender.design(0).controlName("God_buttonJournalConfirmation");
        FormControl    God_buttonJournalPickingList            = sender.design(0).controlName("God_buttonJournalPickingList");
        FormControl    God_buttonJournalPackingSlip            = sender.design(0).controlName("God_buttonJournalPackingSlip");
        FormControl    God_buttonJournalInvoice                = sender.design(0).controlName("God_buttonJournalInvoice");
        select CustConfirmJour
            where CustConfirmJour.SalesId == SalesTable.SalesId;
        if(CustConfirmJour)
        {
            God_buttonJournalConfirmation.enabled(true);
        }
        else
        {
            God_buttonJournalConfirmation.enabled(false);
        }

        select WMSPickingRoute
            where WMSPickingRoute.transRefId == SalesTable.SalesId;
        if(WMSPickingRoute)
        {
            God_buttonJournalPickingList.enabled(true);
        }
        else
        {
            God_buttonJournalPickingList.enabled(false);
        }
        select CustPackingSlipJour
           where  CustPackingSlipJour.SalesId == SalesTable.SalesId;
        if(CustPackingSlipJour)
        {
            God_buttonJournalPackingSlip.enabled(true);
        }
        else
        {
            God_buttonJournalPackingSlip.enabled(false);
        }
        select CustInvoiceJour
            where CustInvoiceJour.SalesId == SalesTable.SalesId;
        if(CustInvoiceJour)
        {
            God_buttonJournalInvoice.enabled(true);
        }
        else
        {
            God_buttonJournalInvoice.enabled(false);
        }


    }

}





Thanks
Akshay


How to use Form Data source Activeted method in D365




Here i am going to write code in Active event of form-> data source.

SalesTable-> DS->salesLine-> event-> copy event of Activated.

1. create class.
2. paste copied event in class.
3. class Data source by
        FormDataSource      fds = sender.formRun().dataSource("SalesLine");
        SalesLine           salesline = fds.cursor();

4. put logic according you.
       








class Aks_SODSSLActivated
{
   
   

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Activated)]
    public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
       
        real                             Amount,amt1;
        Tax                              tax;
       
      
        FormDataSource      fds = sender.formRun().dataSource("SalesLine");
        SalesLine           salesline = fds.cursor();
       

       
        if(salesline.LineDisc > 0 || salesline.LinePercent >0)
        {
            fds.object(fieldNum(SalesLine,Aks_givenDiscount)).allowEdit(false);
          
            salesline.Aks_givenDiscount =0;
        }
         
        else
        {
          
            fds.object(fieldNum(SalesLine,Aks_givenDiscount)).allowEdit(true);
        }
      
            }

}






Thanks
Akshay


How to use Field Modified in Datasource in ax D365

How to use Field Modified in Datasource in ax D365

Here we are going to use Modified in item field in form datasource. 
form-> salestable -> Ds-> salesline -> itemid-> event-> modified -> copy event.

create new class
Paste event in this class

Call  datasource.

 FormDataSource      SalesLine_ds   = sender.dataSource();

 SalesLine           SalesLine      = SalesLine_ds.cursor();







class Aks_NetAmtBasedonGivenDisc
{
   
       [FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, ItemId), FormDataFieldEventType::Modified)]

    public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        EcoResCategory                   ecoResCategory;
        InventTable                      inventTable;
        EcoResProductCategory            ecoResProductCategory;
        EcoResCategoryHierarchy          ecoResCategoryHierarchy;
        InventOnhand                     inventOnHand;
        InventDimParm                    inventDimParm;
        InventQty                        availQty;
        InventDim                        inventdim;
        //ItemId                           itemid;
        SalesTable                       salestable;
        real                             Amount,amt1;
        Tax                              tax;

      
        FormDataSource      SalesLine_ds   = sender.dataSource();
        SalesLine           SalesLine      = SalesLine_ds.cursor();
        ItemId              ItemId         = sender.getValue(0);
   
        select InventTable
            where inventTable.ItemId == ItemId;//SalesLine.ItemId;
          
        while select ecoResProductCategory
            where ecoResProductCategory.Product == inventTable.Product
           join ecoResCategoryHierarchy
            where ecoResCategoryHierarchy.RecId == ecoResProductCategory.CategoryHierarchy
           && ecoResCategoryHierarchy.Name == "Retail Product Category"
        {
            select ecoResCategory
                where ecoResCategory.RecId == ecoResProductCategory.Category;
           
            SalesLine.God_AllowedDiscount = ecoResCategory.GOD_AllowedDiscount;
        }
        Amount = Tax::calcTaxAmount(SalesLine.TaxGroup,SalesLine.TaxItemGroup,systemDateGet(),SalesLine.CurrencyCode,SalesLine.LineAmount,TaxModuleType::Sales);
     
        SalesLine.Aks_TotalAmoutWithVAT = SalesLine.LineAmount + Amount;
 


    }
 }






Thanks
Akshay