Hello Community,
I would like to filter data in my dashboard (Freedom UI) from Approval object based on the role of the currently logged in user in the Approver field. However I could not find a way to achieve this at design time (possible way was to use a macro but it does not allow this). Please see attached screen shot. I have used a View to fetch data from the Approval object. Is there a way to filter the data possibly through code or from the View itself?
Like
Hello,
Unfortunately, it is not yet possible to build a filter with Approvals object when using the new Approval mechanism with the basic tools of our application.
As a workaround, you can try to develop a filter for your needs, but even using development methods, it is unlikely that you will be able to use the Approvals object for filtering.
You can try to develop filtering as follows:
1) Change the dashboard filter logic before loading data using the filter. This should be done by manipulating with the _Data_PredefinedFilter property of the dashboard. See example below:
Here we used the HandleViewModelInitRequest (page is opened) and we have access to the filter of the dashboard using request.$context.IndicatorWidget_5jpo3v5_Data_PredefinedFilter (IndicatorWidget_5jpo3v5 should be changed to the code of the dashboard we are interested in). To get the filter use the code:
let dashboardFilter = await request.$context.IndicatorWidget_5jpo3v5_Data_PredefinedFilter;
Then you can manipulate with the filter and set the value back as
request.$context.IndicatorWidget_5jpo3v5_Data_PredefinedFilter = dashboardFilter (or any other variable name that is used to manipulate the filter)
2) Manipulate with the already received response and set the value to the dashboard. This is easy with dashboards of the metrics type, but more complex with dashboards of the list type, and it cannot be done on the HandleViewModelInitRequest event. In this case you need to use sdk.Model to get some data for comparison (something like below):
const ceoFilter = new sdk.CompareFilter(sdk.ComparisonType.Equal, new sdk.ColumnExpression({
columnPath: "JobTitle"
}), new sdk.ParameterExpression({
value: "CEO"
}));
const contactModel = await sdk.Model.create("Contact");
const contacts = await contactModel.load({
attributes: ["Id", "Name", "JobTitle"],
parameters: [{
type: sdk.ModelParameterType.Filter,
value: ceoFilter
}]
});
And then modify the received data set from the dashboard (this dataset can be retreived from the dashboard.
End of problem not decided
However, we understand that this is not ideal for your specific needs.
We want to assure you that we have created a request for our development team to implement this functionality in future versions of our application. We understand the importance of providing our clients with the best possible experience and will work hard to implement the changes you have suggested.
Thank you again for bringing this to our attention, and please do not hesitate to reach out if you have any further questions or concerns.