In
Microsoft dynamics enterprise portal 2012, you can apply
the range to the data sources in the init() method of the data set. But
as far
as I know, when the data sources are linked via active join (or some
other
join), then its not possible to apply the range through the dataset (may
be its
possible, but at least I did not find any help regarding this), so I
decided to apply the range to one of the data sources. Here are the
steps:
- Override the init() method of your datasource at which you want to apply the range.
Notice that "dsLeftMenus" is the name of the datasource which contains the dataset.
3. Now handle the CreatingDataSetRun event as follows:
You can also send the enum values through EP like:
Now go the AOT -> Data Sets-> DataSources-> Your datasource, and override the "init" method of your data source. Add the following x++ code to add the range to the data source. Notice that you can receive the argument which you sent through enterprise portal as follows:
element.args().parm() [will return "my value" in this case."]
public void init()
{
{
//please be noted that QueryBuildDataSource and QueryBuildRange are declared just before super().
QueryBuildDataSource qbds;
QueryBuildRange qbr;
super();
// Retrieve the data source.
qbds = this.query().dataSourceName(this.name());
// Clear the existing range.
qbds.clearRange(fieldNum(HierarchyTreeTable,HierarchyId));
// Add a new range to hierarchyId.
qbr = qbds.addRange(fieldNum(HierarchyTreeTable,HierarchyId));
qbr.value(queryValue(element.args().parm())); //element.args().parm() will get the value from EP.
QueryBuildRange qbr;
super();
// Retrieve the data source.
qbds = this.query().dataSourceName(this.name());
// Clear the existing range.
qbds.clearRange(fieldNum(HierarchyTreeTable,HierarchyId));
// Add a new range to hierarchyId.
qbr = qbds.addRange(fieldNum(HierarchyTreeTable,HierarchyId));
qbr.value(queryValue(element.args().parm())); //element.args().parm() will get the value from EP.
//set the range status. We set it Hidden because we dont want to allow the user to modify it.
qbr.status(RangeStatus::Hidden);
qbr.status(RangeStatus::Hidden);
//and execute the query.
this.executeQuery();
}
this.executeQuery();
}
Conclusion: In
this article, we have explored how to send a parameter argument from EP to the
dataset and applied range to the data
source according to that parameter.
If someone has a better solution to do so, I will be grateful to him if he shares with us.
If someone has a better solution to do so, I will be grateful to him if he shares with us.
Thanks.. this works like a charm...
ReplyDelete