Thursday, September 2, 2021

How to enable Maintenance Mode in Tier 1 Environments / VMs in D365 FO


Maintenance mode is helpful for us in lot of scenarios where we need some environmental changes in our D365 Finance and Operations platform.

Any kind of change in Financial dimensions and configuration keys are only allowed if the environment is in Maintenance Mode.

In Tier2 or Sandbox environments we get this option very easily in the Maintain Menu in LCS

Environment Page but if the same activity needs to be done Tier 1 environments which we access through  RDP then there is a different approach altogether.


Let's take a look step by step : - 


1) Stop the following services : - 


    a) Microsoft Dynamics Batch Management Service


    b) Microsoft Dynamics Data Import and Export Service


    c) World Wide Web Service


2) In the environment open Sql Server Management Studio and sign in to Sql Server using axdbdmin login

3) Click on New Query option

4) Run the below SQL script : -


    USE AXDB;


    update SQLSYSTEMVARIABLES SET VALUE = 1 where PARM = 'CONFIGURATIONMODE'


5) Once done turn on the services mentioned in Step 1


6) Now the environment should be in Maintenance Mode and you can perform various actions such as

       activate Financial Dimensions and Enable/Disable Configuration keys.


Once the work is done in the SQL statement in step 4 instead of SET VALUE = 1 make it 0 which will turn off the maintenance mode.


Note : - You might need to restart the environment if after the above steps the maintenance mode is not enabling or disabling.



********* Please mention your queries if any in the comments area ***************


How to get the details of the selected records through x++ in D365 FO

 

Sometimes we come across a scenario where we need to get the data from the selected records in a form contained in a grid.

For these kind of scenarios MultiSelectionHelper class has always been useful to achieve the same.


Let us look at an example mentioned below : -



MultiSelectionHelper          selectionHelper = MultiSelectionHelper::construct();
Set                           selectedRecords = new Set(Types::Record);
ABCTable                  abcTable;

selectionHelper.parmDataSource(ABCTable_DS); 

abcTable  = selectionHelper.getFirst();  

if (abcTable.RecId)
{
    while(abcTable)
    {
        selectedRecords.add(abcTable);
        
        info(strFmt('Selected record.. %1',abcTable.myField));
        
        abcTable = selectionHelper.getNext();
    }
}




That's all for now. Please let us know your questions or feedback in comments section !!!!

How to export data from table to excel through x++ in D365 FO


 Exporting data to excel might be required in most of the scenarios where Data Integration is involved.

Excel can be proved as one of the most significant applications for Data Transformation and manipulations.

Let us see how can achieve the data export using x++ coding standards :-
u



DocuFileSaveResult           saveResult;

Table1                       table1details , table1datasource , table1update;

PurchAgreementHeader         purchAgreementHeader;

TransDate                    delDate;

FormDataSource               fdsTable1det = sender.formRun().dataSource('Table1');


table1datasource = fdsTable1det.cursor();

select firstonly purchAgreementHeader where purchAgreementHeader.RecId ==                                                                                                            table1datasource.AgreementHeaderRefRecId;

while select forupdate table1update where                                                                                                                         table1update.AgreementHeaderRefRecId ==                                                                                                                table1datasource.AgreementHeaderRefRecId
{
     if(table1update)
     {
           ttsbegin;

           if(InventItemPurchSetup::findDefault(table1update.ItemId).LeadTime != 0)
           {
                delDate =  DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone()) +     InventItemPurchSetup::findDefault(table1update.ItemId).LeadTime;
                
                table1update.RequestedDeliveryDate = delDate;
           }

          table1update.PurchQty = 0;

          table1update.RemarksComments = "Enter your comments here";

          table1update.update();

          ttscommit;

     }

}

saveResult = DocuFileSave::promptForSaveLocation("Table1", "xlsx", null, "Table1 Details");

if (saveResult && saveResult.parmAction() != DocuFileSaveAction::Cancel)
{
    saveResult.parmOpenParameters('web=1');

    saveResult.parmOpenInNewWindow(false);

    System.IO.Stream workbookStream = new System.IO.MemoryStream();

    System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();

    using (var package = new ExcelPackage(memoryStream))
    {
        var currentRow = 1;
        
        var worksheets = package.get_Workbook().get_Worksheets();

        var Table1Worksheet = worksheets.Add("Export");

        var cells = Table1Worksheet.get_Cells();

        OfficeOpenXml.ExcelRange cell = cells.get_Item(currentRow, 1);

        System.String value = "Item Number";

        cell.set_Value(value);

        cell = null;

        value = "Unit of Measure";

        cell = cells.get_Item(currentRow, 2);

        cell.set_Value(value);

        cell = null;

        value = "Requested Delivery Date";

        cell = cells.get_Item(currentRow, 3);

        cell.set_Value(value);

        cell = null;

        value = "Remarks and Comments";

        cell = cells.get_Item(currentRow, 4);

        cell.set_Value(value);

        cell = null;

        value = "Purchase Quantity";

        cell = cells.get_Item(currentRow, 5);

        cell.set_Value(value);

        cell = null;

        value = "Agreement Quantity";

        cell = cells.get_Item(currentRow, 6);

        cell.set_Value(value);

        cell = null;

        value = "Remaining Quantity";

        cell = cells.get_Item(currentRow, 7);

        cell.set_Value(value);

        cell = null;

        value = "Released Quantity";

        cell = cells.get_Item(currentRow, 8);

        cell.set_Value(value);

        cell = null;

        value = "Received Quantity";

        cell = cells.get_Item(currentRow, 9);

        cell.set_Value(value);

        cell = null;

        value = "Invoiced Quantity";

        cell = cells.get_Item(currentRow, 10);

        cell.set_Value(value);

        cell = null;            

        value = "Agreement Line Record Id";

        cell = cells.get_Item(currentRow, 11);

        cell.set_Value(value);

        cell = null;

        value = "Agreement Header Record Id";

        cell = cells.get_Item(currentRow, 12);

        cell.set_Value(value);



        while select table1details where table1details.AgreementHeaderRefRecId ==                                                                       purchAgreementHeader.RecId
        {

              currentRow ++;

              cell = null;

              cell = cells.get_Item(currentRow, 1);

              cell.set_Value(table1.ItemId);

              
              cell = null;

              cell = cells.get_Item(currentRow, 2);

              cell.set_Value(table1.ProductUnitOfMeasure);

              
              cell = null;
              
              cell = cells.get_Item(currentRow, 3);

              cell.set_Value(any2Str(table1.RequestedDeliveryDate));


              cell = null;

              cell = cells.get_Item(currentRow, 4);

              cell.set_Value(any2Str(table1.RemarksComments));

              cell = null;


               cell = cells.get_Item(currentRow, 5);

               cell.set_Value(any2Str(table1.PurchQty));


               cell = null;

               cell = cells.get_Item(currentRow, 6);

               cell.set_Value(any2Str(table1.AgreementQty));

               
               cell = null;

               cell = cells.get_Item(currentRow, 7);

               cell.set_Value(any2Str(table1.RemainingQty));

           
               cell = null;

               cell = cells.get_Item(currentRow, 8);

               cell.set_Value(any2Str(table1.ReleasedQty));

               
               cell = null;

               cell = cells.get_Item(currentRow, 9);

               cell.set_Value(any2Str(table1.ReceivedQty));

               
               cell = null;

               cell = cells.get_Item(currentRow, 10);

               cell.set_Value(any2Str(table1.InvoicedQty));


               cell = null;          

               cell = cells.get_Item(currentRow, 11);

               cell.set_Value(any2Str(table1.AgreementLineRefRecId));

               
               cell = null;

               cell = cells.get_Item(currentRow, 12);

               cell.set_Value(any2Str(table1.AgreementHeaderRefRecId));
               
       }
       
       package.Save();

  }
       memoryStream.Seek(0, System.IO.SeekOrigin::Begin);

       DocuFileSave::processSaveResult(memoryStream, saveResult);

}


That's all for now. Please let us know your questions or feedback in comments section !!!!

How to reverse Free Text Invoice Voucher entries without Dialog

 Hey Folks ,  This blog post is in continuation of the previous post for Reversing Free Text Invoice Voucher entries with Dialog. Only diffe...