Get Free Trial
Get Free Trial

flexmonster.setReport(): Cannot read property 'firstChild' of undefined

Resolved
Nate Anderson asked on November 29, 2018

I’m using a recursive function I wrote to call flexmonster.getMembers(), automating the drill-downs to a specific depth.
I am constructing a drills object, then calling setReport().
The function I wrote is:

function getMembersRecursively(hierarchy, member) {

flexmonster.getMembers(hierarchy, member, function(members) {

for (var i = 0; i < members.length; i++) {
var thisOne = members[i].uniqueName;
if (!members[i].isLeaf && !/([0-9][0-9][0-9][0-9])/.test(thisOne)) {
rows.push( {tuple: [thisOne]} );
getMembersRecursively(hierarchy, thisOne);
}
}
})
}

 
The error message is:

VM6019:1 Uncaught TypeError: Cannot read property 'firstChild' of undefined
at Function.j6.create (flexmonster.js:9)
at q1.B1.n9 (flexmonster.js:9)
at f.B1.cQ (flexmonster.js:9)
at f.s6.dispatch (flexmonster.js:9)
at f.Cy (flexmonster.js:9)
at f.Bn (flexmonster.js:9)
at XMLHttpRequest.xhr.onreadystatechange (flexmonster.js:9)
j6.create @ flexmonster.js:9
B1.n9 @ flexmonster.js:9
B1.cQ @ flexmonster.js:9
s6.dispatch @ flexmonster.js:9
f.Cy @ flexmonster.js:9
f.Bn @ flexmonster.js:9
xhr.onreadystatechange @ flexmonster.js:9
XMLHttpRequest.send (async)
(anonymous) @ VM6019:1
f.load @ flexmonster.js:9
B1.count @ flexmonster.js:9
B1.load @ flexmonster.js:9
f1.Rg @ flexmonster.js:9
c8.Rg @ flexmonster.js:9
z6.fC @ flexmonster.js:9
L.fC @ flexmonster.js:9
g8.(anonymous function) @ flexmonster.js:9
getMembersRecursively @ index.js?version=20181116:92
(anonymous) @ index.js?version=20181116:101
z6.fC @ flexmonster.js:9
L.fC @ flexmonster.js:9
g8.(anonymous function) @ flexmonster.js:9
getMembersRecursively @ index.js?version=20181116:92
expandHierarchiesForExport @ index.js?version=20181116:107
(anonymous) @ flexmonster.toolbar.js?2.404:1739

5 answers

Public
Ian Sadovy Flexmonster November 29, 2018

Hello Nate,
 
Thank you for the question.
I think the issue is that getMembers() cannot be executed simultaneously.
So, you need to create something like a queue of requests and process them one by one.
 
Please let me know if it helps.
 
Regards,
Ian

Public
Nate Anderson November 29, 2018

Ian, 
In other words, by trying to use the function recursively, the library is unable to handle the numbers of calls and ends up throwing an error?

Public
Tanya Gryshko Flexmonster November 30, 2018

Hello, Nate,
Thank you for your reply.
Yes, currently such requests should be sent one by one. Our development team does agree that simultaneous execution is more convenient for such cases. We have added your request to our backlog and will consider it when planning future improvements. For now, we suggest processing such requests one by one.
Please let me know in case of other questions.
Regards,
Tetiana

Public
Nate Anderson November 30, 2018

Tanya,
Thank you for your reply. In this case, I cannot use expandAllData(), since the client doesn’t want the lowest level of data in the hierarchy when generating certain reports. 
Additionally, the members of the hierarchy change on a regular basis, so manually modifying the report.json to set the desired drills is not a viable solution. Finally, since this is an OLAP data source, I cannot use expandData(). Having finer grained control over how deep to drill into the hierarchy would be tremendously helpful.

Public
Dmytro Zvazhii Flexmonster December 3, 2018

Hello Nate,
Thank you for writing. As my colleagues have already mentioned, the component cannot handle multiple getMembers() requests simultaneously. Currently, the recommended solution is to manage the requests order on your own.
In such case, you can create an additional structure which should store the queue of getMembers() requests. You just need to achieve the situation when there is only one getMembers() request is handled by Flexmonster in a time. After that, the approach suggested by you is still possible.
Please let us know if there is anything else we can help you with.
Regards,
Dmytro

Please login or Register to Submit Answer