Wednesday 7 February 2024

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only.

a. Goto LCS-->Asset Library-->NuGet Packages-->Import

b. Pick the 4 PU files 

      






2.  In DevOps Goto Artifacts and click on Connect to Feed


3. Click on NuGet.exe and Get the tool and download the exe file to C:\Temp folder










Click on NuGet.exe and Get the tool and download the exe file to C:\Temp folder

Edit the below two files and change the path according to and run in power shell as administrator
---
1. AddSource

C:\temp\nuget.exe sources Add -Name "NuGet.exe Project setup Key =" -Source "https:NuGet.exe Project setup Key value =/index.json" -Username "mallikarjun" -password "DevOps Token"

-----
2. Script2Push

$Token = "DevOps token"
$FeedURL = "https:NuGet.exe Project setup Key value =/index.json"
$Username = "mallikarjun"

$LocalFileApplicationSuiteBuild  = "C:\_Col\NuGetPackages\Microsoft.Dynamics.AX.ApplicationSuite.DevALM.BuildXpp.nupkg"
$LocalFileApplicationBuild  = "C:\_Col\NuGetPackages\Microsoft.Dynamics.AX.Application.DevALM.BuildXpp.nupkg"
$LocalFilePlatformBuild  = "C:\_Col\NuGetPackages\Microsoft.Dynamics.AX.Platform.DevALM.BuildXpp.nupkg"
$LocalFileCompilerTools  = "C:\_Col\NuGetPackages\Microsoft.Dynamics.AX.Platform.CompilerPackage.nupkg"

C:\temp\nuget.exe sources push -Name "NuGet.exe Project setup Key =" -Source $FeedUrl -UserName "mallikarjun" -password $Token

C:\temp\nuget.exe push -Source "Baettr" -ApiKey Az $LocalFileApplicationSuiteBuild -Timeout 3000                                    
C:\temp\nuget.exe push -Source "Baettr" -ApiKey Az $LocalFileApplicationBuild -Timeout 3000  
C:\temp\nuget.exe push -Source "Baettr" -ApiKey Az $LocalFilePlatformBuild -Timeout 3000                                   
C:\temp\nuget.exe push -Source "Baettr" -ApiKey Az $LocalFileCompilerTools -Timeout 3000  


5. After running the above commands, it will update the  Artifacts version. Copy the version and update in TFS 



 






Wednesday 3 January 2024

A Guide to Finding Table Field Types Enum in D365FO Using X++

 Certainly! Enum fields in Dynamics 365 Finance and Operations (D365FO) are treated as Int64 data types. When comparing enum values, you need to use the enum2int function to convert the enum value to its corresponding integer representation. Let's extend the previous code to demonstrate how to compare enum values using the DictField.baseType() method:


static void FindFieldTypeAndCompareEnum(Args _args) { DictTable dictTable; DictField dictField; int fieldType; // Table name str tableName = 'CustTable'; // Field name str fieldName = 'CustClassification'; // Get the table dictionary dictTable = new DictTable(tableName2id(tableName)); if (dictTable) { // Get the field dictionary dictField = dictTable.fieldName2Id(fieldName); if (dictField) { // Get the field type fieldType = dictField.baseType(); // Display the field type info(strFmt("Field Type of %1.%2: %3", tableName, fieldName, fieldType)); // Check if the field is an Enum if (fieldType == Types::Enum) { CustClassification custClassification = CustClassification::High; // Convert the enum value to integer using enum2int int enumIntValue = enum2int(custClassification); // Retrieve the field's enum type str enumTypeName = dictField.typeName(); // Display the enum comparison result info(strFmt("Comparing %1.%2 with %3: %4", tableName, fieldName, custClassification, enumIntValue == enum2int(enumTypeName, dictField.enumType()))); } else { warning(strFmt("Field '%1' is not an Enum in table '%2'", fieldName, tableName)); } } else { warning(strFmt("Field '%1' not found in table '%2'", fieldName, tableName)); } } else { warning(strFmt("Table '%1' not found", tableName)); } }

Explanation:

  1. enum2int: The enum2int function is used to convert an enum value to its corresponding integer representation.

  2. typeName: The typeName method of DictField returns the type name of the field, which is useful for obtaining information about the enum type.

  3. enum2int(enumTypeName, enumValue): This is used to convert an enum value to its integer representation based on the enum type name.

  4. Comparing Enum Values: The code checks if the field type is an Enum and then compares an enum value (e.g., CustClassification::High) with the stored value in the table.

Switch (dictField.baseType())

{

Case Type::Enum :

dictEnum = new DictEnum(dictField.enumID());

for (i = 0; i < dictEnum.values(); i++)

{

info (strfmt(“Enum value :  %1“,dictEnum.value2Name(i))); 

}

}

Usage:

  1. Copy the extended code into the X++ editor in the Dynamics 365 Finance and Operations development environment.

  2. Replace the values of tableName and fieldName with the desired table and enum field names.

  3. Run the job, and the output will display the field type and the result of comparing the enum value with the stored value in the table.

This extended code provides a way to determine if a field is of enum type and how to compare enum values using the DictField.baseType() method in D365FO X++.

A Guide to Finding Table Field Types in D365FO Using X++

Introduction:


In Microsoft Dynamics 365 Finance and Operations (D365FO), developers often need to determine the field types of various table fields for customization or reporting purposes. In this blog post, we'll explore how to find the table field type using X++ code.


Code Snippet:


Let's start with a simple X++ code snippet that you can use to find the field type of a specific field in a table. In this example, we'll use the CustTable table and the AccountNum field:


static void FindFieldTypeExample(Args _args)

{

    DictTable dictTable;

    DictField dictField;

    int fieldType;


    // Table name

    str tableName = 'CustTable';

    

    // Field name

    str fieldName = 'AccountNum';


    // Get the table dictionary

    dictTable = new DictTable(tableName2id(tableName));


    if (dictTable)

    {

        // Get the field dictionary

        dictField = dictTable.fieldName2Id(fieldName);


        if (dictField)

        {

            // Get the field type

            fieldType = dictField.baseType();


            // Display the field type

            info(strFmt("Field Type of %1.%2: %3", tableName, fieldName, fieldType));

        }

        else

        {

            warning(strFmt("Field '%1' not found in table '%2'", fieldName, tableName));

        }

    }

    else

    {

        warning(strFmt("Table '%1' not found", tableName));

    }

}



Explanation:

  • DictTable and DictField classes: These classes are part of the X++ dictionary framework and are used to access metadata information about tables and fields.
  • tableName2id: This method converts the table name to its corresponding ID, which is used to create a DictTable instance.
  • fieldName2Id: This method is used to get the field dictionary based on the field name.
  • baseType: The baseType method of DictField returns the base data type of the field.
  • info and warning: These are methods used to display messages to the user. info is used for general information messages, while warning is used for non-fatal issues.

Usage:

  • Copy the provided code into the X++ editor in the Dynamics 365 Finance and Operations development environment.
  • Replace the values of tableName and fieldName with the desired table and field names.
  • Run the job, and the output will display the field type of the specified field in the specified table.

Conclusion:

With this X++ code snippet, you can easily find the field type of any table field in Dynamics 365 Finance and Operations. This information is valuable for developers working on customizations, integrations, or reporting solutions within the D365FO environment. Feel free to customize the code further based on your specific requirements.

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only. a. Goto LCS-->Asset Libra...