on 2020 Jun 30 4:56 PM
Hey Community,
i have a huge challenge. I have a analytic query in the backend and i want to compare a few values and calculate with them. I was able to create a rule which can compare on value with the other and i am also able to calculate. Unfortunately my program is really slow because i use around 4 of these rules on one page and everytime there is an odata call to the backend which takes a lot of time(10-20 sec per page).
Here a short description of what i want to do:
Get KPI grouped by Products for last month (Value1).
Get KPI grouped by Products for Last Year (Value 2).
Compare Value 1 with Value 2 and return the deviation.
etc...
Issue is that i am not possible to store the Value 1 and use it later in other rules. Result is here that i have to get the Value again from the backend when there is a new rule. I am also not able to use ".read(Services, Entity, QueryOption, etc)" 2 times in one rule and compare those values because they are objects when i try to use them 😞
So, at the end it is working but really slow. I heard something about clientData but i am not sure how to use to store values somewhere at runtime 😞 Would be great if you could help. Here is an example of my rule:
export default function GetPicturePath(context) {
//This is the first Value. I used the queryoptions to get the Values for this week. Later i compare this with the result of the .read
var binding = context.getBindingObject().SL; return context.read('/ServiceLevel/Services/AllSL.service', 'Z_Q_SL', [], '$filter=LastMonth eq \'' + 1 + '\'&$select=ArticleName,SL').then( function (result) { if (result.length > 0) { var ServiceLevel = result.getItem(0).SL; return (binding - ServiceLevel).toFixed(2); } else { return 200; } }).catch(function (error) { alert(error); }); }
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Fabian,
There are two ways to easily persist values in your MDK application.
If the values need to be persisted across launches of the app then you can use application settings. Just remember to clean up your values if you reset/logout of the app. If you delete the app any saved values will be automatically cleared.
If you only need to store them in memory for the current session then you can use Client Data. Client data is associated to a UI element and will persist only for the life of that element. If you are looking to store state for the life of the application then typically you store it in Client Data at the Main Page level since the main page is usually loaded once and not reloaded during the application execution.
In your rule you can then retrieve the stored value and use it in the comparison without having to recalculate the value.
—Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Bill,
thanks for your answer!
I still have issues to set this value and to get it later in another rule.
I have now two rules:
#1
export default function SetValueOne(clientAPI){
var pageproxy = clientAPI.evaluateTargetPath('#Page:Main/#Control:SectionedTable0/#Value');
pageproxy.setValue(5);
}
#2
export default function GetValueOne(clientAPI){
return clientAPI.evaluateTargetPath('#Page:Main/#Control:SectionedTable0/#Value');
}
But my result is still empty 😞
Would be sooo great if you could help here again 🙂 Some kind of example code snippet would be great. 🙂
Kind Regards
Fabian
User | Count |
---|---|
72 | |
19 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.