Performance Tool in D365FO


Performance Tool in D365FO
Today, I found standard feature of performance optimization in Dynamics 365 For Finance and Operations ....

Microsoft called this feature as Performance tool


You can find the navigation of this tool as below... 


You will find lots of option here to optimization, Over internet I didn't find any documentation of this feature. So I am sharing some items i have explored.

There is Text box where we can Enter of  the number of records on which we want to check performance using this tool.


Microsoft Divide this Feature in 4 Category

  1. Data  Manipulation
  2. Query
  3. Temp DB & In Memory
  4. Cache 


Data Manipulation

In this MS Checking the performance of 
Insert  
Update
Record Insert List
 Insert Record set
update record set
delete from


Query

In this section testing will perform on the below points


  1. Large Buffer read
  2. Cluster Index
  3. Unique index with cache hit
  4. Unique index without cache hit
  5. Non-Unique Index

Temp DB & In Memory

In this section we can check the performance on Temp DB and In Memory....  

Cache

The same number of records will store in cache ...


Important 
Note that running for 1,000 records will take approximately 1 minute, so be careful using larger numbers not to run into form timeouts. The max record count is 100,000.

FormHasMethod extension in D365FO

 FormHasMethod extension in D365FO


Every developer who has started working on D365FO faces this issue that when we create a method in the form of Extension

For verification of method exists or not in the run time, we can use Global::formHasMethod but it does not work with form extensions

So I advise everyone to use the below code is working... 


Source Link


using  System.Object;
using  Microsoft.Dynamics.Ax.Xpp;
using  System.Reflection;
    [ExtensionOf(classStr(Global))]
 final class Global_Extension
{
    static boolean formHasMethod(FormRun _fromRun, IdentifierName _methodName)
    {
        boolean flag= next formHasMethod(_fromRun_methodName);

        if (flag==true)
        {
            flag= Global::VerifyformExtensionHasMethod(_fromRun_methodName);
        }

        return ret;
    }

    private static boolean VerifyformExtensionHasMethod(FormRun _formRun, IdentifierName _methodName)
    {
        

        try
        {
            System.Object[] extensions = ExtensionClassSupport::GetExtensionsOnType(_formRun.GetType(), true);

            if (extensions)
            {
               System.Type    formExtensionType;
               MethodInfo    mInfo;
             
                var  bindingFlags = BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase;

                for (int i = 0; i < extensions.Length; i++)
                {
                    formExtensionType= extensions.GetValue(i);

                    var info = formExtensionType.GetMethods(bindingFlags);

                    for (int J = 0; J < info .get_Length(); J++)
                    {
                        mInfoinfo .getValue(J);
                        if (mInfo.Name == _methodName)
                        {
                            return true;
                        }
                    }
                }
            }
        }
        catch (Exception::CLRError)
        {
            error(CLRInterop::getLastException().ToString());
        }

        return false;
    }

}



Financial dimension configuration for integrating D365FO


Financial dimension configuration for integrating D365FO




Today, A bug reported to me that complete segments Default Dimensions are not exporting using Data Entity...

Functional share more detail with me Like, they set the default dimension with Positions.
Dimension has 9 segments but while they are exporting using data management framework then 5 dimension segments are missing in the Excel sheet.

Entity Name  > Position default dimensions

Here is the screenshot of the position and the set of dimensions.



Dimension set



Functional Create Export Project and Export the data and download the file




downloaded file screenshot





Resolution

After spending hours of hours and debugging in the code, finally, we found that this is a configuration issue and there is a template configuration form available for Dimension Integration..

General Ledger>Chart of accounts>Dimensions>Financial dimension configuration for integrating 

Here We define a segment that we need to export via integration.....

Navigate to Financial Dimension Configuration for Integration





Select Dimension in which you want to change...

Default is 4 Dimension were set in my case and the same was exporting.




Move your required segment from left to right list page.. for demo purposes I have moved all segments.

Save the record a confirmation prompt show on your screen... click on yes.  



Now Execute the Export project and download the export file.




Here is the final result... After changing in 





Dimension configuration working fine for me ...

Please feel free to contact me In case of any issue you are facing during the implementation of this blog


Override Lookup AX7 & D365FO


Override Lookup AX7 & D365FO



Here is a small example to override lookup.


copy the lookup event handler of the field and  paste the event into any class




/// <summary>
    ///
    /// </summary>
    /// <param name="sender">receiving value in parameter</param>
    /// <param name="e">receiving value in parameter</param>
    [FormControlEventHandler(formControlStr(PayrollEmployerTaxRegion, Overview_StateId), FormControlEventType::Lookup)]
    public static void Overview_StateId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
           /// write your lookup code here

if the control or field already has a lookup to we need to cancel parent lookup execution otherwise we will get an exception.

below code you can use to cancel parent lookup ---
        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        //cancel super() to prevent error.
        ce.CancelSuperCall();
      }


Here is the complete code sample 


/// <summary>
    ///
    /// </summary>
    /// <param name="sender">receiving value in parameter</param>
    /// <param name="e">receiving value in parameter</param>
    [FormControlEventHandler(formControlStr(PayrollEmployerTaxRegion, Overview_StateId), FormControlEventType::Lookup)]
    public static void Overview_StateId_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        SysTableLookup      sysTableLookup  = SysTableLookup::newParameters(tableNum(LogisticsAddressState), sender);
        Query               query           = new Query();

        // Filter lookup to only show US states
        query.addDataSource(tableNum(LogisticsAddressState)).addRange(fieldNum(LogisticsAddressState, CountryRegionId)).value(LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId);

        // Sort the lookup by state Id
        query.dataSourceTable(tableNum(LogisticsAddressState)).addOrderByField(fieldNum(LogisticsAddressState, StateId), SortOrder::Ascending);

        // Add fields
        sysTableLookup.addLookupfield(fieldNum(LogisticsAddressState, StateId));
        sysTableLookup.addLookupfield(fieldNum(LogisticsAddressState, Name));

        // Run lookup
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;

        //cancel super() to prevent error.
        ce.CancelSuperCall();
    }


Card Pattern in Grid D365FO & AX 7



Card Pattern in Grid  D365FO & AX 7


Yesterday, One of my team member had task to show data in Grid in Card Style like work space, in the initial state we were trying to create work space tile dynamically but no luck.


After spending hour i found an page with pattern design Card.



Here are the some steps to achieve the below task. 




Step-1 Create Custom form and data-source and Grid,

Step-2 apply the patter of list page on design node of the form and follow the design pattern instruction.



Step-3 Now select the grid and change the following  properties of Grid.
  1. Style= List
  2. Extended Style= CardList


Step-4 Now add the Group in the grid and apply the pattern of business Card.

Step-5 Follow the instruction of business card design pattern and add the required field.




Step-6 Create Display menu item set object properties with you newly created form. 
Step-7 Create menu extension and drag the display menu item on it
Step-8 Last steps to perform build and sync.


Now login on you D365FO instance and verify the form...

for me its working fine, kindly check the below screenshot for reference.




Please feel free to contact me if you are facing any issue during implementation of this blog.



Batch job Execution for ALL Companies



Batch job Execution for ALL Companies

void run()
{
while select crossCompany purchTable

{

    changeCompany(purchTable.DataAreaId)

{
// todo your logic
}

}

}

Grid/List row color change using method override D365



Grid/List row color change using method override D365

Today, I received the requirement from my functional to change the row color Grid/List page on any specific condition... 

As we all knows in custom form its really easy to achieve but in my case I need to do this on exists form using method override/Event handler of Data source..

So I start searching over internet and community and found that lots of people were facing the same issue because this feature is not available in extension...

After the resolution of this task i decide to share with everyone..


There is an event available in data source OnDisplayOptionInitilized. I copied the event handler and paste on my class.



Following are the code 

[FormDataSourceEventHandler(formDataSourceStr(JmgRegistrationTouchAssignedJobs, JmgJobTable), FormDataSourceEventType::DisplayOptionInitialize)]
public static void JmgJobTable_OnDisplayOptionInitialize(FormDataSource sender, FormDataSourceEventArgs e)
{

}

Now another challenge is ready for me to find the display Option and set the back-ground color..
After one hour of efforts found a class FormDataSourceDisplayOptionInitializeEventArgs which we can use to set the color




Following is the complete code 
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(JmgRegistrationTouchAssignedJobs, JmgJobTable), FormDataSourceEventType::DisplayOptionInitialize)]
public static void JmgJobTable_OnDisplayOptionInitialize(FormDataSource sender, FormDataSourceEventArgs e)
{
FormDataSourceDisplayOptionInitializeEventArgs fdsoption;
fdsoption= e as FormDataSourceDisplayOptionInitializeEventArgs;
fdsoption.displayOption().backColor(WinAPI::RGB2int(161,161,255));
}


Here is the result of my all efforts.



Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...