Hey, I created a flow where I want to export data from my database in sharepoint to excel. If I start the flow, there is no problem, but when someone else wants to start them, he gets badrequest 502 in the application and in flow there is information that the script is not shared or has been removed.
and this is script:
function main(workbook: ExcelScript.Workbook, csv: string) {
let sheet = workbook.getWorksheet("Sheet1");
/* Convert the CSV data into a 2D array. */
// Trim the trailing new line.
csv = csv.trim();
// Split each line into a row.
let rows = csv.split("\r\n");
// Split each line into a row.
if (csv.search(/\r\n/) > - 1) {
rows = csv.split("\r\n");
} else if (csv.search(/\n/) > - 1) {
rows = csv.split("\n");
} else if (csv.search(/\r/) > - 1) {
rows = csv.split("\r");
}
rows.forEach((value, index) => {
/*
* For each row, match the comma-separated sections.
* For more information on how to use regular expressions to parse CSV files,
* see this Stack Overflow post: https://stackoverflow.com/a/48806378/9227753
*/
let row = value.match(/(?:,|\n|^)("(?:(?:"")*[^"]*)*"|[^",\n]*|(?:\n|$))/g);
// Remove the preceding comma.
row.forEach((cell, index) => {
row[index] = cell.indexOf(",") === 0 ? cell.substr(1) : cell;
});
// Create a 2D-array with one row.
let data: string[][] = [];
data.push(row);
// Put the data in the worksheet.
let range = sheet.getRangeByIndexes(index, 0, 1, data[0].length);
range.setValues(data);
});
// Add any formatting or table creation that you want.
let newTable = workbook.addTable(sheet.getUsedRange(), true);
// Set number format for range H:H on sheet
sheet.getRange("A:A").setNumberFormatLocal("@");
// Set number format for range H:H on sheet
sheet.getRange("B:B").setNumberFormatLocal("@");
// Sort on table: newTable column index: '6'
newTable.getSort().apply([{ key: 6, ascending: true }]);
}
Solved! Go to Solution.
Hi @Piter_D ,
Unfortunately, executing script can only use the script owner's connection.
Please take a look at this.
You could find solution in this post.
Best Regards,
Wearsky
and the strange thing is that flow despite the failure to excel file is still created
Hi @Piter_D ,
Unfortunately, executing script can only use the script owner's connection.
Please take a look at this.
You could find solution in this post.
Best Regards,
Wearsky
User | Count |
---|---|
102 | |
40 | |
29 | |
23 | |
16 |
User | Count |
---|---|
132 | |
52 | |
50 | |
36 | |
26 |