Hello all,
I'm working on creating a Flow for a PowerApp to export information from a DataTable to a CSV. I was able to get the download portion to work, but it doesn't pull the information I'm looking for. I'm new to JSON, but I believe the answer lies in a script for it.
What I'd like to do is pull the top 50 records out of the SharePoint List connected to the DataTable in PowerApps based on SortOrder.Ascending of 'Inv Adj Retail.' Anything under the top 50 sorted by this column doesn't need to be on the Excel spreadsheet. The SharePoint List can hold over 700,000 items, which is information the folks using the app don't need. I have the scripting information below. Please let me know if you need anything more.
"Download" button script in PowerApps (I know FirstN brings down the first # of data without sorting):
Set(varWhichDownloadInfo, JSON(ShowColumns(FirstN(MyData,50),Department,'Item Description','Inv Adj Units','Inv Adj Retail',PtS),JSONFormat.IndentFour));
Set(varExportToCSV,PowerAppsToExcelDup.Run(varWhichDownloadInfo).linkoutput);
Download(varExportToCSV);
Flow JSON Parse script:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"Department": {
"type": "string"
},
"InvAdjRetail": {
"type": "number"
},
"InvAdjUnits": {
"type": "integer"
},
"ItemDescription": {
"type": "string"
},
"PtS": {
"type": [
"number",
"null"
]
}
},
"required": [
"Department",
"InvAdjRetail",
"InvAdjUnits",
"ItemDescription",
"PtS"
]
}
}
DataTable script (there's a lot more to it in the real PowerApp. I'm trying this in a test so I don't break the real thing):
Sort(MyData,Value('Inv Adj Retail'),SortOrder.Ascending)
I attached a picture of the flow, and I generated the Schema from a sample by putting the varWhichDownloadInfo into a text label.
And ultimately, I would like it to only pull what is displayed in the DataTable when being downloaded. I've looked into a few different sources (w3schools, Microsoft Power Platform Community, Stack Overflow) and they don't seem to quite touch on what I need. I'm also wondering if I need to put the data from the DataTable into a variable to get it to parse or if that's even possible?
I appreciate any help you can provide.