Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: DataGrab: importing data into Grid field
Status | Resolved |
Add-on / Version | DataGrab 4.0.5 |
Severity | |
EE Version | 7.1.2 |
Daniel Szczukiewicz
Sep 07, 2022Hi Brian,
I wan to import data into Grid field. Basically it works but only for data nested into 5th level. If data is nested on 6th level and deeper then is not copied properly.
Please check attached screen.
Also, does DataGrab supports Relationship field into Grid field?
Thanks.
BoldMinded (Brian)
Sep 08, 2022
Hi Daniel. Please share with me a sample of the file you are trying to import. I just need 2-3 entries, not the full file.
BoldMinded (Brian)
Sep 08, 2022
There is no explicit limitation on the depth of the xml/json nodes in the code, it should keep recursing to any depth. Are you sure the xml/json values at that depth are valid? Have you tried any other types of content in that field?
Daniel Szczukiewicz
Sep 08, 2022
Hi Brian. Here is an example of data I’m trying to import into Grid field I mentioned.
Daniel Szczukiewicz
Sep 08, 2022
I was trying “text” & “number” “fields” - no luck.
But when I tried to import less-nested data into “text/number” fields then everything was fine.
BoldMinded (Brian)
Sep 08, 2022
To answer your other question no it doesn’t currently support importing assigned Relationships that are children of a Grid field, and I’m unsure when I’ll be able to get around to adding that support.
BoldMinded (Brian)
Sep 08, 2022
Can you share all of that JSON file? It’s not valid JSON and I’m having trouble manually fixing it. Is this a public URL/endpoint somewhere I can get the JSON response from?
BoldMinded (Brian)
Sep 08, 2022
Nevermind, I got it formatted.
Daniel Szczukiewicz
Sep 08, 2022
Here its the limit of characters so I cannot paste it here. It’s not a public endpoint.
I’ve sent it on your e-mail.
BoldMinded (Brian)
Sep 08, 2022
Can you share access to your CP? Or provide screenshots of every step of your DataGrab configuration of this import? Sorry for so many questions but I’m trying to replicate this locally and I just need more details.
Daniel Szczukiewicz
Sep 08, 2022
Sure, questions are good 😉
I work locally so cannot provide CP access. However I attached a few screenshots.
BoldMinded (Brian)
Sep 08, 2022
As for the relationship import, I haven’t tested yet, but since you have a unique team id, if you create a separate import to import the teams, then you might be able to set the value of the relationship field on import to the team id in the json file, and it might create the related entry data.
Daniel Szczukiewicz
Sep 08, 2022
Good tip. I will check it.
Daniel Szczukiewicz
Sep 08, 2022
Nope, it doesn’t work. In DataGrab settings I’ve chosen team id in relationship field but it doesn’t connect properly to data from other channel. Relationship field inside grid field doesn’t work at all.
Regarding nested data… The first row of grid field has full data. This is strange.
BoldMinded (Brian)
Sep 08, 2022
I think the issue is because of the depth of your data. The code is specifically looking for item/0/item depth, but yours is item/0/0/item, so it’s not able to iterate correctly over the sub-nodes. Since I’m on vacation this week, and will likely be slammed with work next week when I get back, I’m not entirely sure when I’ll be able to dive deeper into this. Sorry.
Daniel Szczukiewicz
Sep 08, 2022
Brian, thanks for your help.
I hope you will find some time later on for this “issue”.
Thanks.
Daniel Szczukiewicz
Sep 09, 2022
Brian, I simplified JSON tree and now can grab all data into Grid field. Unfortunately I found out more strange behaviors…
1) If in JSON I have 18 items but set up 10 in “Import in batches” field then in the Grid I have rows from 11 to 18. No first 10 rows. If I set up 5 then I have rows 16-18 only (no first 15 rows). If 1 then I get 1 row only, the last one. But if I set up 18 or more (so to cover all items in JSON) then everything works fine. Strange.
2) If in JSON any key is 0 - example: “draw”:0 - then DataGrab saves “null” in Grid field instead “0”.
BoldMinded (Brian)
Sep 13, 2022
Can you share a sample of the simplified JSON that I can test with? I still want to figure out why the other version doesn’t work either, but I haven’t found time to look into it further.
Daniel Szczukiewicz
Sep 14, 2022
Sure, here is a simplified JSON data (4 items only):
BoldMinded (Brian)
Sep 15, 2022
I tried the new simpler format and it does appear to be importing correctly, so that is good. I can’t replicate the “null” value thing. Can you share more detail on that? Screenshot of what you’re seeing in the entry after the import? What value type is the grid column in your Grid field settings?
I still haven’t found time to look into the batch issue. Hope to get to that soon. Sorry for the delays.
Daniel Szczukiewicz
Sep 16, 2022
The value type of Grid field is “number”. When I import data like “draw:0” then this field is just empty.
BoldMinded (Brian)
Sep 16, 2022
I still can’t replicate that. I changed some values to 0 and they all import as 0
What version of mysql do you have?
Daniel Szczukiewicz
Sep 19, 2022
5.7.33
BoldMinded (Brian)
Sep 19, 2022
I’m using MySQL version 8. Not sure I can safely downgrade my environment to 5.7 to test.
The only thing I can suggest is to try editing the AbstractDataType.php file, line 86 which currently looks like this:
and change it to this:
And see if that does anything.
Daniel Szczukiewicz
Sep 20, 2022
Nope, it didn’t help. But what helped is I changed field type from “number” to “string” and now it’s working properly.