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.



Batch Job Multi threading D365FO AX7


Multi-threaded batch job



Normally, when we schedule our "Run Base Batch" class as a batch job, it will create a single task. Which will be responsible to execute the complete process in a single thread.

But, As you know like AX-2009 and AX-2012. In D365FO We can add multiple AOS servers in a single batch group and they can process multiple tasks simultaneously. 

In this demo, I will show, How to create a multi-threading Batch job.
following are the steps
Step-1 Create a table for demo purposes in our demo we keep the table name is SLD_DemoTable.





Step-2 Create a class with the name SLD_DemoBusinessLogic and write your business logic in this class.
In the demo, I write only to insert records in a table and show you guys how it works.






Reference Code

class SLD_DemoBusinessLogic
{

    public void processInit(VendTable _vend)
    {
        SLD_DemoTable   SLDDemoTable;

        SLDDemoTable.clear();
        SLDDemoTable.VendName=_vend.name();
        SLDDemoTable.VendAccount=_vend.AccountNum;
        SLDDemoTable.insert();

    }

}

Step-3 Create a batch job class with the name SLD_DemoMultiThreadTask.
This class we will use as Task in the main batch job.




Step-4 In this class We Create a getter setter to store vend table buffer;
Step-5 Create an object of our business logic class and execute the method



Reference Code

public class SLD_DemoMultiThreadTask extends RunBaseBatch
{
  
  VendTable ventTableBuffer;
    #DEFINE.CurrentVersion(1)
    #LOCALMACRO.CurrentList
        ventTableBuffer
    #ENDMACRO

        public ClassDescription caption()
       
        {
              ClassDescription ret;
          
              ret = 'Update Multiple Thread task';
          
              return ret;
          
        }

    container pack()
    {
        return [#CurrentVersion,#CurrentList];
    }

    public boolean unpack(container _packedClass)
    {
        int version = conPeek(_packedClass,1);
   
        switch (version)
        {
            case #CurrentVersion:
                [version,#CurrentList] = _packedClass;
                break;
            default:
                return false;
        }
        return true;
    }

    public void pramVendBuffer(VendTable _vend)
    {
        ventTableBuffer=_vend;
    }

    public void run()
    {
        try
        {
            SLD_DemoBusinessLogic       SLDDemoBusinessLogic=new SLD_DemoBusinessLogic();

            SLDDemoBusinessLogic.processInit(ventTableBuffer);
     
        }
        catch
        {
            info(strFmt("%1",xSession::xppCallStack()));
        }
    }

}

Step-6 Now Create the main batch job which will respond to create multiple tasks in the single batch job.




Reference Code

class SLD_DemoMultiThreadBatch extends RunBaseBatch
{
    BatchHeader                             batchHeader;

    VendTable        vendTable;
 

    public static void main(Args args)
    {
        SLD_DemoMultiThreadBatch  objMultiThread = new SLD_DemoMultiThreadBatch();

        if (objMultiThread.prompt())
        {
            objMultiThread.run();
        }
    }

    void run()
    {
        SLD_DemoMultiThreadTask                 SLDDemoMultiThreadTask;
       

        try
        {
          
            while select firstonly10 vendTable
            {
                if(this.isInBatch())
                {
                    if(!batchHeader)
                    {
                        batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
                    }
                    batchHeader.parmCaption("Multiple thread batch jobs");
                    SLDDemoMultiThreadTask =  new SLD_DemoMultiThreadTask();
                    SLDDemoMultiThreadTask.pramVendBuffer(vendTable.data());
                    // add tasks to the batch header
                    batchHeader.addRuntimeTask(SLDDemoMultiThreadTask, this.parmCurrentBatch().RecId);
                }

                else
                {

                    // execute your code here when not running in batch
                }
            }
            if(batchHeader)
            {
                // save the batchheader with added tasks
                batchHeader.save();
            }

        }
        catch
        {
            info(strFmt("%1",xSession::xppCallStack()));
        }
    }

    public container pack()

    {

        return conNull();

    }

    public boolean unpack(container packedClass)

    {

        return true;

    }

}


Step-7 Now create an Action menu item and reference our batch job SLD_DemoMultiThreadBatch .




Step-8 Build and sync database and module and run the job.
Step-9 Navigate to your batch job page and find your job and check Job Task.






Step-10  before execution of the batch job check the demo table. 
you can check the below screenshot currently table is empty.


After execution of the job table filled with vendors' names.



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



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