Tuesday 29 January 2019

how to make Dynarent enabled




  • Copy the license file to C:\Temp on the customer’s environment.
  • Find your sql password in LCS (it is in the environment’s information). It is highlighted in the following example:

  • Open Microsoft SQL Server Management Studio and remember the name sql server name. It is highlighted in the following examples:

  • Open command prompt in administrator mode in the customer’s environment and navigate to K:\AosService\PackagesLocalDirectory\Bin
  • Run the following command. Replace <sqlpwd> with your sql password, <sqlserver> with your sql server name and <licenseLocation> with the location of the license file:
§  Microsoft.Dynamics.AX.Deployment.Setup.exe --isemulated true --sqluser axdbadmin --sqlpwd <sqlpwd> --sqlserver <sqlserver> --sqldatabase AXDB --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory --setupmode importlicensefile --licensefilename <licenseLocation>
"C:\Temp\DynaRentLicense.txt” - license location
Servername001 - Server name
sqlpwd@ - Pwd 
Ex: Microsoft.Dynamics.AX.Deployment.Setup.exe --isemulated true --sqluser axdbadmin --sqlpwd sqlpwd@ --sqlserver Servername001 --sqldatabase AXDB --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory --setupmode importlicensefile --licensefilename C:\Temp\DynaRentLicense.txt
  • Open Visual Studio in administrator mode.
  • Perform a database sync.

K:\AosService\PackagesLocalDirectory\Bin>Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser axdbadmin --sqlpwd sqlpwd@ --setupmode maintenancemode --isinmaintenancemode true

Can you open the module System administration -> Setup -> License configuration

(And check whether the DynaRent license is enabled)

You now need to enable DynaRent and sync database. 


[‎1/‎29/‎2019 3:41 PM]  Rico Lamein (RLAME.NL): 
Yes you need to put the environment in maintenance mode first with the following command:
K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir <K:\AosService\PackagesLocalDirectory\Bin --sqlserver> . --sqldatabase axdb --sqluser axdbadmin --sqlpwd ********* --setupmode maintenancemode --isinmaintenancemode true
Where you replace sqlpwd with the password mentioned in LCS

Then you need to restart the AOS service, and then you can enable the license
Also, the > after --bindir and < after --sqlserver should be removed



Friday 18 January 2019

form method event handler + D365

 [PostHandlerFor(formStr(CITWHSPack), formMethodStr(CITWHSPack, closeContainer))]
    public static void CITWHSPack_Post_closeContainer(XppPrePostArgs args)
    {
        FormRun formRun = args.getThis();
        WHSShipmentTable shipmentTable = (formRun.dataSource("WHSShipmentTable") as FormDataSource).getFirst() as WHSShipmentTable;
        if(TMSCarrier::find(shipmentTable.CarrierCode).CITCarrierType !=  CITCarrierCode::None)
        {
            FormButtonControl createlblbtn= formrun.design(0).controlName("CITCreateLabels");
            createlblbtn.clicked();
     
            if(InventLocation::find(shipmentTable.InventLocationId,false).CITWHSConfirmshipmentautomatically == NoYes::Yes)
            {
                //Call WHSShipmentDetails >> ConfirmShipment(ShipmentsActionTab>Shipments>btnOutboundShipConfirm)
                MenuFunction    menuFunction;
                Args            args1 = new Args();
                args1.record(shipmentTable);
                menuFunction = new MenuFunction(menuitemActionStr(WHSShipConfirm), MenuItemType::Action);

                if (menuFunction && menuFunction.checkAccessRights())
                {
                    menuFunction.run(args1);
                }
            }
        }
    }

Sunday 13 January 2019

AX 7 Nice links

https://shyamkannadasan.blogspot.com/2017/04/form-control-event-handler-methods-in.html

Friday 11 January 2019

Add range to Custtrans table of CustOpenBalanceCurrency

class EQNCustOpenBalanceFormEventHandler
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(CustOpenBalanceCurrency, CustTrans), FormDataSourceEventType::Initialized)]
    public static void CustTrans_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
    {
        if( CustParameters::find().FINCustCreditCheckType == FINCustCreditCheckType::BasedonExposure)
        {
            Query q = new Query(querystr(EQNCustOpenBalance));

            FormDatasource CustTrans_DS    = sender.formRun().datasource('CustTrans');
       
            CustTrans_DS.query(q);
        }
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(CustOpenBalanceCurrency, CustTrans), FormDataSourceEventType::QueryExecuting)]
    public static void CustTrans_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)
    {
        if( CustParameters::find().FINCustCreditCheckType == FINCustCreditCheckType::BasedonExposure)
        {
            FormDatasource      CustTrans_DS;
     
            CustTrans_DS    = sender.formRun().datasource('CustTrans');
       
       
            AccountNum  custAccount;
            FormRun element =sender.formRun();
            CustTable custTbl;
            SalesTable salesTable;
            CustInvoiceTable custInvoiceTable;
            CustTrans   custTransTmp;
            CustTransOpen   custTransOpen;
            container       conrecid;
            switch (element.args().dataset())
            {
                case tablenum(CustTable) :
                    custTbl = element.args().record();
                    break;
                case tablenum(SalesTable) :
                    salesTable = element.args().record();
                    custTbl = CustTable::find(salesTable.InvoiceAccount);
                    break;
                case tablenum(CustInvoiceTable) :
                    custInvoiceTable = element.args().record();
                    custTbl = CustTable::find(custInvoiceTable.InvoiceAccount);
                    break;
            }
            while select  * from  custTransTmp
                where   custTransTmp.AccountNum == custTbl.AccountNum
                    join  custTransOpen
                         where custTransOpen.RefRecId == custTransTmp.RecId
            {
                if(!PaymTerm::find(CustInvoiceJour::findFromCustTrans(custTransTmp.Invoice,custTransTmp.TransDate,custTransTmp.AccountNum).salesTable().payment).EQNExcludefromexposurecalculations)
                {
                    conrecid += custTransTmp.RecId;
                }
            }
            CustTrans_DS.query().dataSourceTable(tablenum(CustTrans)).addRange(fieldnum(CustTrans, RecId)).value(con2Str(conrecid));
        }
     
    }

}

Thursday 10 January 2019

Lookups In D365


1.  Build query through lookup method :

/// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(PurchTable, NCMR_OINCMRDispositionCodeId_011), FormControlEventType::Lookup)]
    public static void NCMR_OINCMRDispositionCodeId_011_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        FormRun             formRun          = sender.formRun();
        FormStringControl    NCMRDispositionCode = formRun.design(0).controlName("NCMR_OINCMRDispositionCodeId_011");
        Query query = new Query();
        QueryBuildDataSource qbds;
        SysTableLookup sysTableLookup;
        sysTableLookup = SysTableLookup::newParameters(tableNum(OINCMRDispositionCode), sender);
        sysTableLookup.addLookupfield(fieldNum(OINCMRDispositionCode,NCMRDispositionCodeId));
        sysTableLookup.addLookupfield(fieldNum(OINCMRDispositionCode, Description));
        qbds = query.addDataSource(tableNum(OINCMRDispositionCode));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }

}

2. Build Lookup using Reference Table Lookup :

 [FormControlEventHandler(formControlStr(CustParameters, FormGroupControl1_EQNStandardDayRateCodeint), FormControlEventType::Lookup)]
    public static void FormGroupControl1_EQNStandardDayRateCodeint_OnLookup(FormControl sender, FormControlEventArgs e)
    {        
        CustParameterEventhandler::createLookup(sender);     
    }

    private static void createLookup(FormReferenceGroupControl _ctrl)
    {
        SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tablenum(UnitOfMeasure), _ctrl);
        Query                   query = new Query();
        QueryBuildDataSource    unitMeasureDS;
        unitMeasureDS   =   query.addDataSource(tableNum(UnitOfMeasure));
        unitMeasureDS.addRange(fieldNum(UnitOfMeasure,UnitOfMeasureClass)).value(SysQuery::value(UnitOfMeasureClass::Time));
        sysTableLookup.addLookupfield(fieldNum(UnitOfMeasure,Symbol));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }