I need to make an array from the data shown in "cells", given the following JSON schema. I have tried everything. I just get nonesense errors in flow. Stuff like null returns, and such. Nothing to go on. This thread did not give me enough to go on either:
https://powerusers.microsoft.com/t5/Building-Flows/Retrieving-inner-arrays-for-PowerApps/td-p/259902
I am going to need an array of this:
[{rowNumber (from "rows"), columnId (from "cells"), value (from "cells")}]
Here is my schema:
{
"type": "object",
"properties": {
"statusCode": {
"type": "integer"
},
"headers": {
"type": "object",
"properties": {
"Pragma": {
"type": "string"
},
"Vary": {
"type": "string"
},
"Keep-Alive": {
"type": "string"
},
"Connection": {
"type": "string"
},
"Transfer-Encoding": {
"type": "string"
},
"Cache-Control": {
"type": "string"
},
"Date": {
"type": "string"
},
"Content-Type": {
"type": "string"
},
"Expires": {
"type": "string"
},
"Content-Length": {
"type": "string"
}
}
},
"body": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"version": {
"type": "integer"
},
"totalRowCount": {
"type": "integer"
},
"accessLevel": {
"type": "string"
},
"effectiveAttachmentOptions": {
"type": "array",
"items": {
"type": "string"
}
},
"ganttEnabled": {
"type": "boolean"
},
"dependenciesEnabled": {
"type": "boolean"
},
"resourceManagementEnabled": {
"type": "boolean"
},
"cellImageUploadEnabled": {
"type": "boolean"
},
"userSettings": {
"type": "object",
"properties": {
"criticalPathEnabled": {
"type": "boolean"
},
"displaySummaryTasks": {
"type": "boolean"
}
}
},
"permalink": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"modifiedAt": {
"type": "string"
},
"isMultiPicklistEnabled": {
"type": "boolean"
},
"columns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"version": {
"type": "integer"
},
"index": {
"type": "integer"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"primary": {
"type": "boolean"
},
"validation": {
"type": "boolean"
},
"width": {
"type": "integer"
},
"systemColumnType": {
"type": "string"
}
},
"required": [
"id",
"version",
"index",
"title",
"type",
"validation",
"width"
]
}
},
"rows": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"rowNumber": {
"type": "integer"
},
"expanded": {
"type": "boolean"
},
"createdAt": {
"type": "string"
},
"modifiedAt": {
"type": "string"
},
"cells": {
"type": "array",
"items": {
"type": "object",
"properties": {
"columnId": {
"type": "integer"
},
"value": {
"type": "string"
},
"displayValue": {
"type": "string"
}
},
"required": [
"columnId"
]
}
},
"siblingId": {
"type": "integer"
}
},
"required": [
"id",
"rowNumber",
"expanded",
"createdAt",
"modifiedAt",
"cells"
]
}
}
}
}
}
}
The data in cells is only 3 columns of data. That's all i need. Well at least for this question... there will be another followup, but one step at a time...
Hi @martinav
Could you post a sample data as well? I could look into this.
If you getting null means the data you used to generate the JSON might have value and when you start testing with other data it might have null. So in this instance you can extend the "type": ["string", "null"]. Also look for the required attribute in your schema.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsHi @martinav
I did constructed a flow for you but I couldn't test it because I don't have the data.
Like I mentioned earlier if you have null error extend the type properties in your JSON schema.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsI must say, I'm amazed at what you put together. I'm immensely grateful for your time.
I am familiar with all of the elements of what you are suggesting. I put this together in my flow. I get a null() error. on the Apply to each. (ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['rows']' is of type 'Null'. The result must be a valid array.)
Data is at the end of this post.
Here is my stack:
Sample Data. I may not have the termination correct. I did go to the end of the file and find the "]}}" so I think its right...
{"body":{"id":4549752307115908,"name":"MASTER DRAWING LIST","version":289,"totalRowCount":2274,"accessLevel":"ADMIN","effectiveAttachmentOptions":["LINK","GOOGLE_DRIVE","ONEDRIVE","EGNYTE","BOX_COM","EVERNOTE","FILE","DROPBOX"],"ganttEnabled":false,"dependenciesEnabled":false,"resourceManagementEnabled":false,"cellImageUploadEnabled":true,"userSettings":{"criticalPathEnabled":false,"displaySummaryTasks":true},"permalink":"https://app.smartsheet.com/sheets/VP3W8jGmP7r3j43mMqC7VFwJ5hWmRCQFC556GX51","createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2019-10-28T18:38:05Z","isMultiPicklistEnabled":true,
"columns":[{"id":3898437847541636,"version":0,"index":0,"title":"DRAWING #","type":"TEXT_NUMBER","primary":true,"validation":false,"width":171},{"id":8402037474912132,"version":0,"index":1,"title":"DESCRIPTION","type":"TEXT_NUMBER","validation":false,"width":599},{"id":1083688080435076,"version":0,"index":2,"title":"NOTES","type":"TEXT_NUMBER","validation":false,"width":575},{"id":3796166086289284,"version":0,"index":3,"title":"LAST UPDATED","type":"DATETIME","systemColumnType":"MODIFIED_DATE","validation":false,"width":150},{"id":8299765713659780,"version":0,"index":4,"title":"LAST UPDATED BY","type":"CONTACT_LIST","systemColumnType":"MODIFIED_BY","validation":false,"width":213}],
"rows":[{"id":818468139362180,"rowNumber":1,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2019-01-22T14:55:44Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132,"value":"JS75 General Arrg.","displayValue":"JS75 General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2019-01-22T14:55:44Z"},{"columnId":8299765713659780,"value":"t@company.com","displayValue":"t@company.com"}]},
{"id":3070267953047428,"rowNumber":2,"siblingId":818468139362180,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-09-26T20:46:35Z",
"cells":[{"columnId":3898437847541636,"value":201013.0,"displayValue":"201013"},{"columnId":8402037474912132,"value":"JS75S PRV Dwg. 72784-2-1","displayValue":"JS75S PRV Dwg. 72784-2-1"},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]},
{"id":7573867580417924,"rowNumber":3,"siblingId":3070267953047428,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z",
"cells":[{"columnId":3898437847541636,"value":201015.0,"displayValue":"201015"},{"columnId":8402037474912132,"value":"JS75S316 General Arrg.","displayValue":"JS75S316 General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]},
{"id":6447967673575300,"rowNumber":4,"siblingId":7573867580417924,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z","cells":[{"columnId":3898437847541636,"value":201017.0,"displayValue":"201017"},{"columnId":8402037474912132,"value":"JS75S316 General Arrg. w/Flue","displayValue":"JS75S316 General Arrg. w/Flue"},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]},
{"id":8699767487260548,"rowNumber":5,"siblingId":6447967673575300,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z","cells":[{"columnId":3898437847541636,"value":201020.0,"displayValue":"201020"},{"columnId":8402037474912132,"value":"JS75L General Arrg.","displayValue":"JS75L General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]},
{"id":5040592790022020,"rowNumber":6,"siblingId":8699767487260548,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z","cells":[{"columnId":3898437847541636,"value":201021.0,"displayValue":"201021"},{"columnId":8402037474912132,"value":"JS75H General arrg.","displayValue":"JS75H General arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@copmany.com","displayValue":"n@company.com"}]},
{"id":7292392603707268,"rowNumber":7,"siblingId":5040592790022020,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z","cells":[{"columnId":3898437847541636,"value":201022.0,"displayValue":"201022"},{"columnId":8402037474912132,"value":"JS75XL General Arrg.","displayValue":"JS75XL General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]},
{"id":6166492696864644,"rowNumber":8,"siblingId":7292392603707268,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2018-07-03T18:25:56Z","cells":[{"columnId":3898437847541636,"value":201024.0,"displayValue":"201024"},{"columnId":8402037474912132,"value":"JS75XL-S316 General Arrg.","displayValue":"JS75XL-S316 General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2017-01-10T14:54:30Z"},{"columnId":8299765713659780,"value":"n@company.com","displayValue":"n@company.com"}]}
]}}
Hi @martinav
You are most welcome.
I was getting a different error using the above data. So the error was related to expected integer instead of string. So I did changed the properties to accept integer and string so that I can overcome this error. Could you please try this Parse JSON schema?
Flow ran successfully for me once I modified the integer, string modifications in schema. Let me know how it goes.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsHi @martinav
It looks like you may have rows getting as null. So the data you provided don't have null values and worked for me correctly. I would say add an IF condition above the Apply each loop to check the rows length (use expression) is greater than zero then execute the for each loop. That might resolve your issue.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsWell, we are getting closer...
The data I have was from the Parse JSON using the schema I originally gave.
Your revised schema did work for your scenario. However, when plugging in my source data instead of the trial variable, I still get the null.
I parsed my original parse with your revised schema as well. That did not change my result. The Parse actions succeed, but the apply to each fails.
By the way, the trial dataset yeilds this output.. Which is in dire need of formatting into an array, but I think I can sort that bit out.
Hi @martinav
Thanks for the update. Yes we are getting closer. So to debug the error quite effectively what I generally do is add a compose statement to find the length of the rows or check empty row or not? This way we can find which data it is failing. Are you expecting every time the row value exists or not? If exists it might be data quality issue coming from the source. Good luck and let me know how you get on.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video Tutorials@abm,
I would think the data quality is quite high.
To start with, I dont know what it is even saying. It says something is blank... but i dont know why blank data would matter in the least. I have no idea what i'm looking for. Further, I do not even know how to answer what you ask.
I suppose what I could do, instead of doing the HTML grab, is to paste the ENTIRE dataset into the trial case, see if I get the error, then start chopping data away until it works. (bottom up). That might take a while... but there is some odd stuff at the end of the file. Perhaps its tripping up on that. I'll report back.
@abm ,
Well... it seems to work with whatever data I paste in there. Unfortunately, I cant dump the entire chunk in there because of size limits. However, I chopped some out of the middle to see what it would do with the empty lines at the bottom. It actually handled that just fine. So, I'm not sure what is happening wrongly.
I also discovered that this method is entirely too slow. It looks like the nesting of the data and sorting it out with the loops is going to just be too long. I would have thought once the data grab was done (which actually was the fastest part) then things would fly quickly with all of it in some local register. However, its taking like 2sec a row. Multiply that by just over 2,000 rows, and this is just not happening. I will need to think of another way to handle this. If you have ideas, I'm open.
@abm ,
Took me a while to get back on this one. I'm not sure how to do the condition on this.. How do I check for the empty row? I did try a run after failure on the apply to many action, that did not give me any different results.
Hi @martinav
Nice to hear from you.
Try check using expression @empty(item()?['row'])
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video Tutorials@abm ,
SOrry to keep asking, but where do I put this condition? I think its too late to put it inside the apply to many. It fails there... i think?
Hi @martinav
Check this before the compose whether row is blank or not. The only issue is you need to move all the steps under the true statement.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsDoing this has confirmed that the Apply to each is what is failing. It does not even give the compose a chance to check it. Do you know of a way to check if it is NULL before it executes the apply to each? This is ridiculous, by the way...
Result:
Hi @martinav
Think you are using Parse JSON action before the for each loop. Could you post the run history and schema? That should reveal the blank lines. I was expecting this error should have failed under Parse JSON step before it reach the loop. Anyway run history will reveal this.
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video Tutorials@abm ,
I'm using the scheme you posted.
There are blank lines. If I take a chunk of data before the blank rows, this works fine (without the condition we have been discussing). But, I cannot control when there is a blank line in the smartsheet. Or, I cannot have it fail just because there is an empty line.
Here's an excerpt from where the blank lines appear:
{"columnId":8299765713659780,"value":"neisler@company.com","displayValue":"neisler@company.com"}]},{"id":818468139362180,"rowNumber":2266,"siblingId":2758652070258564,"expanded":true,"createdAt":"2017-01-10T14:54:30Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132,"value":"JS75 General Arrg.","displayValue":"JS75 General Arrg."},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2019-01-22T14:55:44Z"},{"columnId":8299765713659780,"value":"teresa@company.com","displayValue":"teresa@company.com"}]},{"id":5669218913937284,"rowNumber":2267,"siblingId":818468139362180,"expanded":true,"createdAt":"2018-03-13T15:46:42Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132,"value":"STEAM JACKET ASSEMBLY WITH 1\" WELD SOCKET, MONEL","displayValue":"STEAM JACKET ASSEMBLY WITH 1\" WELD SOCKET, MONEL"},{"columnId":1083688080435076},{"columnId":3796166086289284,"value":"2018-03-13T15:46:42Z"},{"columnId":8299765713659780,"value":"nunez@company.com","displayValue":"nunez@company.com"}]},{"id":5559233391421316,"rowNumber":2268,"siblingId":5669218913937284,"expanded":true,"createdAt":"2018-03-13T15:25:31Z","modifiedAt":"2018-03-14T19:27:07Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076,"value":"MN 3/12/18","displayValue":"MN 3/12/18"},{"columnId":3796166086289284,"value":"2018-03-13T15:46:42Z"},{"columnId":8299765713659780,"value":"nunez@company.com","displayValue":"nunez@company.com"}]},{"id":5783755008305028,"rowNumber":2269,"siblingId":5559233391421316,"expanded":true,"createdAt":"2019-10-22T14:27:26Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":1568008325359492,"rowNumber":2270,"siblingId":5783755008305028,"expanded":true,"createdAt":"2019-10-10T19:06:38Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":7284242241087364,"rowNumber":2271,"siblingId":1568008325359492,"expanded":true,"createdAt":"2019-10-09T14:12:18Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":1936217683584900,"rowNumber":2272,"siblingId":7284242241087364,"expanded":true,"createdAt":"2019-10-09T14:12:18Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":7565717217798020,"rowNumber":2273,"siblingId":1936217683584900,"expanded":true,"createdAt":"2019-10-09T14:12:18Z","modifiedAt":"2019-10-09T14:12:18Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":7949280345909124,"rowNumber":2274,"siblingId":7565717217798020,"expanded":true,"createdAt":"2019-10-08T20:10:49Z","modifiedAt":"2019-10-09T14:12:18Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":4478506067355524,"rowNumber":2275,"siblingId":7949280345909124,"expanded":true,"createdAt":"2018-05-17T14:12:13Z","modifiedAt":"2019-12-09T17:12:52Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":1103053113845636,"rowNumber":2276,"siblingId":4478506067355524,"expanded":true,"createdAt":"2018-01-10T14:59:14Z","modifiedAt":"2018-07-03T18:17:16Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":4433333484578692,"rowNumber":2277,"siblingId":1103053113845636,"expanded":true,"createdAt":"2018-03-13T15:25:31Z","modifiedAt":"2018-03-14T19:27:07Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":6685133298263940,"rowNumber":2278,"siblingId":4433333484578692,"expanded":true,"createdAt":"2018-03-13T15:25:31Z","modifiedAt":"2018-03-13T15:25:31Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":1165619286566788,"rowNumber":2279,"siblingId":6685133298263940,"expanded":true,"createdAt":"2018-03-13T15:46:42Z","modifiedAt":"2018-09-25T20:59:29Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},{"id":6122183344842628,"rowNumber":2280,"siblingId":1165619286566788,"expanded":true,"createdAt":"2018-03-13T15:25:31Z","modifiedAt":"2018-03-14T19:27:07Z","cells":[{"columnId":3898437847541636},{"columnId":8402037474912132},{"columnId":1083688080435076},{"columnId":3796166086289284},{"columnId":8299765713659780}]},
Hi @martinav
Thanks for the post. I couldn't find the blank row. I was thinking before it hit the foreach why not do a replace function to remove the blank lines. If you could send me some example data with blank lines I could try replicating your error and do something about it.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogPower Automate Video TutorialsJoin digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!
Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.
User | Count |
---|---|
90 | |
57 | |
40 | |
39 | |
35 |
User | Count |
---|---|
79 | |
66 | |
57 | |
52 | |
42 |