Thursday, February 10, 2022

New operators are added in X++ D365FO

 These are new two operators added to X++ libraries.

 *= 

 /=

Example:

X *= 2
X /= 2

These are short for X = X * 2 and X = X / 2.

Quick entries on document (Sales order, Purchas order.. Etc) In D365FO using Excel

 Login to D365FO URL,

Navigate to Sales order (Sample)

Create new order




Prepare Excel with all Item list

Copy content from excel
Go to Order again, Add CTRL+V (To paste that content)

Result:


On popup Click -> SAVE
and Click -> Save






Wednesday, January 19, 2022

Computed column view method with T-SQL statement in D365FO

 Converting to view computed column method.

T-SQL statment like this way.

return strFmt(@'select top 1 WHT.ACCOUNTNUM from WHSSHIPMENTTABLE as WHT

                           where WHT.WaveId = %1 order by WHT.RECID asc',waveId);

Sunday, January 16, 2022

Convert word stream to PDF file X++ in D365FO

 using AK = Microsoft.Dynamics365.LocalizationFramework.MicrosoftInternalUseOnly.ApiKeys;

using GR = Microsoft.Dynamics365.LocalizationFramework.Repositories.GlobalRepository;

using Microsoft.Dynamics365.LocalizationFramework;

using TL = Microsoft.Dynamics365.LocalizationFramework.Telemetry;

using BCS = Microsoft.Dynamics365.LocalizationFramework.ExternalApi.BCS;

using EA = Microsoft.Dynamics365.LocalizationFramework.ExternalApi;

using Microsoft.Dynamics.ApplicationPlatform.Environment;

using Microsoft.Dynamics.ApplicationPlatform.Environment.Settings;

using Microsoft.Dynamics.AX.Security.AuthenticationCommon;

using Microsoft.Dynamics.AX.Security.ADALClientAuthentication;

using Microsoft.Dynamics.AX.Framework.FileManagement;

class WordToPDFConverter 

{

    /// <summary>

    /// Runs the class with the specified arguments.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>


    public static void main(Args _args)

    {

        System.IO.Stream inputStream; //word stream

        str fileExtension = '.docx';

        System.IO.Stream outputPDFStream; //Pdf stream

        System.IO.Stream    fileStream;

        try

        {

            fileStream  = File::UseFileFromURL('C:\\wordfile\\word1.docx');

        }

        catch

        {

            warning("File not found");

        }

        inputStream =  fileStream;

        BCS.ConvertToPdfRequest request = new BCS.ConvertToPdfRequest();

        BCS.ConvertToPdfResponse response;


        request.FileStream = inputStream;

        request.ClientCorrelationId = newGuid();

        request.ClientName = identifierStr(DynamicsAxElectronicReporting);

        request.FileExtension = fileExtension;


        var ret = new BCS.PdfConversionPageOptions();

        ret.Orientation = BCS.PdfConversionPageOrientation::Portrait;


        request.PageOptions = ret;

        request.LocaleIdentifier = 0;


        AK.IApiKeysProviderService apiKeysProvider = null;

        Microsoft.Dynamics.Client.ServerForm.Contexts.SessionContext sessionContext;

        System.Uri currentUrl = null;

        sessionContext = Microsoft.Dynamics.Client.ServerForm.Contexts.SessionContext::get_Current();

        if (sessionContext)

        {

            currentUrl = sessionContext.get_RequestUrl();

        }

        str ProdUrl = 'https://apikeys.configure.global.dynamics.com';

        System.String configValue = System.Configuration.ConfigurationManager::AppSettings.Get('RCS.GlobalRepoKeysAPIUrl');

        var configProvider = System.String::IsNullOrEmpty(configValue) ? ProdUrl : configValue;

        str authProvd = ERParameterTable::find().RCSApplicationAADUrl;

        if (!authProvd)

        {

            authProvd = (ERParameterTable::isMooncake() ? 'https://configure.global.dynamics.cn' : 'http://configure.global.dynamics.com');

        }

            var s2SAuthProvider = new GR.S2SAuthenticationProvider(authProvd);

            apiKeysProvider = new GR.MicrosoftInternalUseOnly.GlobalRepositoryApiKeysClient(s2SAuthProvider, configProvider);

            var provider = apiKeysProvider;

            var conversionClient = EA.BCS.BcsApiClient::Instance;

            response =  conversionClient.ConvertToPdf(request, provider, TL.ElectronicReportingMappingTelemetryLogger::Log);

            if (response.IsValidResponse)

            {

                outputPDFStream = response.ResultStream;

                File::SendFileToUser(outputPDFStream,'word1.pdf');

            }        

    }

}


Monday, October 4, 2021

SSRS file error message: The number of defined parameters is not equal to the number of cell definitions in the parameter panel (D365FO)

 Error: 

SSRS file error message: The number of defined parameters is not equal to the number of cell definitions in the parameter panel

In D365FO - SSRS report

Workaround solution:

1. Create new design (Shouldn't duplicate it from existing design)

2. Copy all objects from Old design and paste it in new design

3. Save report

4. Rebuild and deploy reports

Thursday, September 2, 2021

The data source is not embedded within a (parent) data source. (PU43 10.0.19 error) in D365FO

 The data source is not embedded within a (parent) data source. 


Write COC for FORM DS extension method

(In my case, SalesTable (Form) & SalesLine_IN (DS)). Even IN region localization not enabled.

Note: This has been fixed by MS as part of PU43 (10.0.19) + QU

1. Code fix solution (Temporary)

// Temporary fix for "The data source is not embedded within a (parent) data source." Error while opening All Sales order form after upgrade PU43 (10.0.19)

void init()

{

next init();

this.insertIfEmpty(false);

this.allowCreate(false);

}

2. Workaround solution (Temporary)

   //Changed personalize view to Standard view

Monday, July 12, 2021

Get Category Hierarchy levels X++ D365FO

 class GetCategoryLevels

{

    public static void main(Args _args)

    {

// TOP to BOTTOM hierarchy level data

        void loopchild(RefRecId     _recId)

        {

            EcoResCategory   ecoResCategoryChk, ecoResCategoryChild;

            while select ecoResCategoryChk

                where ecoResCategoryChk.ParentCategory ==  _recId

            {

                //Child query insert to table Write ur logic

                Info(ecoResCategoryChk.Name);

                ecoResCategoryChild.clear();

                select firstonly  ecoResCategoryChild

                    where ecoResCategoryChild.ParentCategory ==  ecoResCategoryChk.RecId;

                if(ecoResCategoryChild)

                {

                    loopchild(ecoResCategoryChild.ParentCategory);

                }

            }

        }

        EcoResCategory  ecoResCategory;

        EcoResProductCategory   ecoResProductCategory, ecoResProductCategoryCHk;

        RefRecId parentCategory;

        select firstonly  ecoResCategory

            where ecoResCategory.Name == "Refrigeration";

        parentCategory = EcoResCategory.RecId;

        if(parentCategory)

        {

            //Parent query insert  - Write ur logic

            Info(ecoResCategory.Name);

            loopchild(parentCategory);

        }

    }

}

Wednesday, June 16, 2021

Set range for SrsReportRunController through X++ D365FO

 Map queryContracts  = reportController.parmReportContract().parmQueryContracts();

        MapEnumerator mapEnumerator = queryContracts.getEnumerator();

        while(mapEnumerator.moveNext())

        {

            Query query = mapEnumerator.currentValue();

            if(query)

            {

                QueryBuildDataSource qbds = query.dataSourceTable(tableNum(WHSWorkLine)); 

                if(qbds)

                {

                    qbds.addRange(fieldNum(WHSWorkLine, ShipmentId)).value(queryValue(_shipmentTable.ShipmentId));

                }

            }

        }

Function to check whether DS is exists or not in QUERY D365FO

QueryBuildDataSource findFirstDsForTable(Query _q, TableId _tableId)

{

    QueryBuildDataSource ds;

    int i;

    for (i = 1; i <= _q.dataSourceCount(); i++)

    {

        ds = _q.dataSourceNo(i);

        if (ds.table() == _tableId)

        {

            return ds;

        }

    }

    return null;

}


Wednesday, May 12, 2021

Skip Inventory reservation on Sales order lines in D365FO

[ExtensionOf(classStr(InventUpd_Reservation))] final class InventUpd_ReservationCls_SAN_Extension {     void updateNow()     {         if(mo...