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;
    }

}



Support Faryal's Cusine


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


Support Faryal's Cusine


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...