Need a special offer?Find out if your project fits.
+

Unable to reset reports using setReport method

Answered
Ali Eissa asked on August 12, 2020

Hello,
When I set the report using `setReport` method. I get this message below

 Uncaught TypeError: Cannot assign to read only property 'uniqueName' of object '#<Object>

I am trying to update a report that looks like

{
"dataSource":{
"type":"csv",
"filename":"https://<path-to-remote-csv>",
"requestHeaders":{
"Authorization":"Bearer <Token>"
}
},
"options":{
"grid":{
"type":"flat"
}
},
}

with one that looks like

{
"dataSource":{
"type":"csv",
"filename":"https://<path-to-another-remote-csv>",
"requestHeaders":{
"Authorization":"Bearer <token>"
}
},
"slice":{
"rows":[
{
"uniqueName":"0_Date.Year"
},
{
"uniqueName":"0_Date.Month"
},
{
"uniqueName":"0_Date.Day"
},
{
"uniqueName":"1_Review"
},
{
"uniqueName":"2_City"
},
{
"uniqueName":"3_Type"
},
{
"uniqueName":"statement_expression"
},
{
"uniqueName":"language"
},
{
"uniqueName":"statement_topic"
},
{
"uniqueName":"statement_opinion"
},
{
"uniqueName":"sentiment"
},
{
"uniqueName":"group_topic"
},
{
"uniqueName":"group_opinion"
}
],
"measures":[
{
"uniqueName":"4_Price",
"aggregation":"sum"
},
{
"uniqueName":"group_uniq_doc_count",
"aggregation":"sum"
}
],
"flatOrder":[
"0_Date.Year",
"0_Date.Month",
"0_Date.Day",
"1_Review",
"2_City",
"3_Type",
"4_Price",
"statement_expression",
"language",
"statement_topic",
"statement_opinion",
"group_uniq_doc_count",
"sentiment",
"group_topic",
"group_opinion"
]
},
"options":{
"grid":{
"type":"flat"
}
},
"version":"2.8.12",
"creationDate":"2020-08-12T16:27:31.704Z"
}

If I remove the slice field from the second report then it works fine. Would very much appreciate any help.
 
Cheers,
Ali

6 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster August 14, 2020

Hi Ali,
 
Thank you for posting your question.
 
So far, we haven't managed to reproduce the described issue. Do you think you could send us a dummy data set with which the issue is reproducible?
 
Looking forward to hearing from you.
 
Regards,
Mykhailo

Public
Ali Eissa August 17, 2020

Hi Mykhailo,
I was able to solve problem by making sure that I was saving a clone of the report. I used

flexmonster.setReport(JSON.parse(JSON.stringify(report)))

Cheers,
Ali

Public
Oleg June 8, 2021

I'm having same problem. When I use setRport methods sometimes it doens't load and shows this error.
If I use

flexmonster.setReport(JSON.parse(JSON.stringify(report)))

then flexmonster.clear() doens't work and setReport process data doesn't stop

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster June 9, 2021

Hi Oleg,
 
Are there any specific steps you take to reproduce this behavior other than calling the method in a way you've mentioned?
 
Also, would it be possible for you to send us a sample project where this issue is reproducible? If not, having your report configurations and a dummy data set might be helpful as well.
 
Looking forward to your response.
 
Best regards,
Mykhailo

Public
Oleg June 10, 2021

Are there any specific steps you take to reproduce this behavior other than calling the method in a way you’ve mentioned?

 
I have templates. Each template has it's own report config. When I switch template, my redux thunks starts fetching data.  I pass ref to thunk and after fetching I'm using this ref to update my pivot.
const updatePivot = (flexmonsterRef) => {
const res = ...fetching 
const formattedReport = formatReport(res);
flexmonsterRef.current?.flexmonster.setReport(formattedReport);
flexmonsterRef.current?.flexmonster.highcharts?.getData({type: 'bar'}, drawChart, drawChart);
}
Know when we switch between templates , flexmonster doesn't stop processing and repeat it on every click to template.
For that I used clear() method and with this method it throws this error.

 Uncaught TypeError: Cannot assign to read only property 'uniqueName' of object '#<Object>
Public
Mykhailo Halaida Mykhailo Halaida Flexmonster June 11, 2021

Hi Oleg,
 
The structure of your solution is not yet entirely clear to us – do you think you could send us a sample project so that we can investigate the issue further? 
 
Thank you in advance.
 
Regards,
Mykhailo

Please login or Register to Submit Answer