Hello,
In this case youâre connected to a hierarchy, not just date/time. The difference is a hierarchy groups members so that youâre able to see dates at different levels, such as months, day and years (depending on what your Time Dimension is setup as). Unfortunately your script wonât work like that because youâre taking the memberTime
property, which is DateTime, and then assigning it to lowerBoundaryValue
which is supposed to be a member value object. DateTime objects have no concept of âlevelâ.
So you need to set those properties to a member value like in this example here.
The question though is: what member values should you use? For this there are two answers. One is that you could not use a member value at all, and instead use a token. For example there is a âCurrent Monthâ token which could have an offset of -1, or just use the âPrevious Monthâ token instead. Using this way is fairly straight forward, and you can follow this example on how to do it. Getting the ID of the token to use can be a bit more work and there is an API call to assist in getting all of them.
The second answer is to find the corresponding member by date/time. One way to do this is to use the getPreviousMember
and getNextMember
calls on the hierarchyService. If the member you have on your parameter value is at the same level, such as the month, then these calls will return the next or previous member at the same level. The other way is to just query directly for a member that matches the specified date/time at the specified level, such as:
var getMemberDef = this.getService("HierarchyService").getMember(hierarchyId, {
"hierarchyUniqueName": dateParam.parameterValue.hierarchyUniqueName,
"levelUniqueName": dateParam.parameterValue.levelUniqueName,
"memberDateTime": from.addMonths(-1)
});
getMemberDef.done(function (memberValue) {
if (memberValue) {
...
}
});
Youâd have to do the same thing for the âtoâ value. Since these are async calls you may also want to mark e.isAsync
as true
and resolve e.deferred
when both are done, if youâre doing this inside of an action.