Sunday, 27 June 2021

D 365 FO Enable or disable & Mandatory or Non Mandatory based on Checkbox field using Extension Class

  [FormControlEventHandler(formControlStr(EcoResProductParameters, [FieldName]), FormControlEventType::Modified)]

    public static void [FieldName]_OnModified(FormControl sender, FormControlEventArgs e)

    {

        FormCheckBoxControl allowVehicleCreation = sender.formRun().design().controlName(formControlStr(EcoResProductParameters,[FieldName]));

        FormStringControl allowVehicleCreationGroup = sender.formRun().design().controlName(formControlStr(EcoResProductParameters,[FieldForWhichValidationRequired]));


        if(allowVehicleCreation.value() == NoYes::Yes)

        {

            allowVehicleCreationGroup.mandatory(true);

            allowVehicleCreationGroup.enabled(true);

        }

        else

        {

            allowVehicleCreationGroup.mandatory(false);

            allowVehicleCreationGroup.enabled(false);

        }

    }


Thank you

Keep Daxing :)

D 365 FO Command / Script to make the Development Env to Maintenance Mode

//Run the Command in Powershell

Maintenance On

C:\AOSService\PackagesLocalDirectory\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir C:\AOSService\PackagesLocalDirectory --bindir C:\AOSService\PackagesLocalDirectory\bin --sqlserver . --sqldatabase axdb --sqluser [AXDBAdminUsername] --sqlpwd [Password] --setupmode maintenancemode --isinmaintenancemode true


Maintenance off

C:\AOSService\PackagesLocalDirectory\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir C:\AosService\PackagesLocalDirectory --bindir J:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser [AXDBAdminUsername] --sqlpwd [Password] --setupmode maintenancemode --isinmaintenancemode false



//Run the Query on MSSQL Query browser

select Value from sqlsystemvariables a where a.PARM = 'configurationmode'

update sqlsystemvariables set VALUE = 1 where PARM = 'configurationmode'



The best result you'll get it after restarting IIS services (iisreset) cmd



Thank you,

Keep Daxing :)

Wednesday, 23 June 2021

D 365 FO to refresh caller FormDataSource from a Extension Class

 class UpdatePurchLine_Extension

{

static void main(Args args)

{

PurchLine purchLine;

FormDataSource purchLine_DS;

purchLine_DS = args.record().dataSource();

;


purchLine = args.record();


//Set of Code

purchLine_DS.executeQuery();

purchLine_DS.refresh();

}


}


Thank you,

Keep Daxing :)

Tuesday, 22 June 2021

D 365 FO Enable or disable field based on condition using Extension Class

 [FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchLine), FormDataSourceEventType::Activated)]

    public static void PurchLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {

        //Declaration of the Form Datasource

        FormDataSource              fds             = sender.formRun().dataSource(formDataSourceStr(PurchTable,PurchLine));

        PurchLine                   purchLine       = fds.cursor();

        FormRun                     fr              = sender.formRun();

        PurchParameters             purchParameters = PurchParameters::find();

        boolean                     allowEdit = true;

        //Form Tab page declaration for allowing to customize

        FormTabPageControl          ftpc = fr.design(0).controlName("TabLineFixedAsset");

        

        allowEdit = purchParameters.BER_AllowEditPOLineAfterReceipt;

        //condition

        if(PurchLine.PurchStatus == PurchStatus::Received)

        {

            //controls where the enable set true or false based on the condition execution

            fds.object(fieldNum(PurchLine ,PurchQty)).allowEdit(allowEdit);

            fds.object(fieldNum(PurchLine ,PurchPrice)).allowEdit(allowEdit);

            fds.object(fieldNum(PurchLine ,LineAmount)).allowEdit(allowEdit);

            fds.object(fieldNum(PurchLine ,DiscAmount)).allowEdit(allowEdit);

            fds.object(fieldNum(PurchLine ,DiscPercent)).allowEdit(allowEdit);

           //Fixed asset tab enable false if the Ststus is received.

            ftpc.allowEdit(false);

        }

    }


Thank you,

Keep Daxing :)

Thursday, 10 June 2021

D365 FO Refresh Called from after function call

 Hi All,

The below code will help you to refresh the call from after the data operations, for me I'm refreshing the PurchTable form after duplicating line from exiting lines.


 protected static  void updateCaller(PurchTable  _purchTable)

    {

        PurchTable  purchTable = _purchTable;//purchTable::find(PurchLine::findRecId(_args.record().RecId));

        Object callerPurchTableDataSource = FormDataUtil::getFormDataSource(purchTable);


        if (callerPurchTableDataSource)

        {

            callerPurchTableDataSource.reread();

            callerPurchTableDataSource.refresh();


            if (formDataSourceHasMethod(callerPurchTableDataSource, identifierStr(reReadLines)))

            {

                callerPurchTableDataSource.reReadLines();

            }

        }

    }


Thank you,

Keep Daxing :)