How in Dynamics365: Use Drill Through to send parameters in Chart Design

Mateen Ahmed
3 min readAug 3, 2023

--

Today we will learn how to send in parameters when we click on an item in a chart form. Let’s take a look at the following figure.

Pie chart

We want to open up another form when we click on any item. This is easy to do and can be achieved by applying the Series and going to the properties of SysBuildChartMeasure.

In the properties change the MenuItemDisplay to Display and MenuItemName to the Display Item you have created which opens up the form. In my case, it is the following:

Properties in Series

This will indeed open up the form, but what if we want to send in multiple parameters to apply ranges? We can achieve this with the help of the Drill Through method chart pattern.

  /// <summary>
/// Calling another form and sending parameters.
/// </summary>
/// <param name = "_contextObject"></param>
public void DrillThrough(str _contextObject = '')
{
//super(_contextObject);
Args args;
FormRun formRun;

List myList = new List(Types::String);

myList.addEnd(MAStoreTable.MAStoreId);
myList.addEnd(MonthFilter.valueStr());
myList.addEnd(YearFilter.valueStr());

//Call the form using a Menu Item
args = new Args();
args.parm(myList.toString());



formRun = new menufunction(menuItemDisplayStr(NumberofSales), MenuItemType::Display).create(args);

formRun.init();
formRun.run();
}

What we did is make a list of all the parameters we want to send and convert that list to a string to send it through the parm function in the args.

It is important to comment out the super call inside the Drill Through other wise Menu Item would be called twice and the form will open twice as we have also called the menu item through the properties in Series.

Now in the child form, we can override the ExecuteQuery method of the data source and apply the respective ranges. In my case, I will have the following code:

/// <summary>
/// Overriding execute query to apply ranges and accept parameters.
/// </summary>
public void executeQuery()
{
// Accepting parameters.
str obj = this.formRun().args().parm();

container params = str2con(obj);

// Converting from container to string
str id = conPeek(params,1);
str month = conPeek(params,2);
str year = conPeek(params,3);

// Applying ranges.
this.query().dataSourceName("MASalesType").clearRanges();
QueryBuildRange qbr;
qbr = this.query().dataSourceName("MASalesType").addRange(fieldNum(MASalesType, MAStoreId));
qbr.value(strAlpha(id));
QueryBuildRange qbr1;
qbr1 = this.query().dataSourceName("MASalesType").addRange(fieldNum(MASalesType, MAMonth));
qbr1.value(strAlpha(month));
QueryBuildRange qbr2;
qbr2 = this.query().dataSourceName("MASalesType").addRange(fieldNum(MASalesType, MAYear));
qbr2.value(strAlpha(year));
super();
}

This would apply the respective ranges to the data source.

Happy Learning!

--

--

Mateen Ahmed

Dyanmics365 Finance and Operations Consultant. Currently working at Devsinc Ventures, Lahore, Pakistan