Hi @Dorinda,
To preface, the guide is quite old and recently you don't have to manually parse json via these text functions. You could remove the Join action from your flow and provide viable column names in your Select (Title instead of A/ and so on). Use the Output from the Select as your response, not the Join. To fetch it to a collection leverage the recent ParseJSON() function:
Clear(GetMyTasks);
ForAll(
Table(ParseJSON(JsonOutput)),
Collect(
GetMyTasks,
{
//I replaced my A/ and B/ column names in the Select action with Title and Item, adjust or add where necessary
Title: Text(ThisRecord.Value.Title),
Item: Text(ThisRecord.Value.Item)
}
)
)
Reza Dorrani has a very good guide on this function.
That being said, below you will find the way proposed in the LinkedIn Learning post.
I did some testing on my end (with a test JSON that mimics the post output) and the following solution worked (integrated it into your code):
ClearCollect(
GetMyTasks,
AddColumns(
Split(
JsonOutput,
"\n"
),
"Title",
Mid(Value, Find("A/",Value)+5,Find("B/",Value)-(Find("A/",Value)+8)),
"AssignedTo",
Mid(Value, Find("B/",Value)+5,Find("C/",Value)-(Find("B/",Value)+8)),
"State",
Mid(Value, Find("C/",Value)+5,Find("D/",Value)-(Find("C/",Value)+8)),
"ID",
Mid(Value, Find("D/",Value)+5,Find("}",Value)-(Find("D/",Value)+6)) //careful, here it is +6 not +8
)
);
The single record issue was caused because you are currently splitting on Char(13) but the linebreak is hardcoded as a \n string. In other words the split separator should be "\n".
The post did not go into detail why it was using +4 +1 and +4 +2 +2, so I will explain this briefly as well. This way the code and random numbers will make a lot more sense 🙂
The Mid() function expects 3 parameters - with the 3rd being optional: Mid(string, startingPosition, {NumberOfChars}). This function allows you to extract text from other text values starting from a certain position or between 2 positions, the latter is used in the code above.
If we take a look at the value that is received by the Power App, it looks as follows (my test JSON):
{"A/":"title1","B/":"item1"}"\n"{"A/":"title2","B/":"item2"}
Split(JsonOutput, "\n") will result in a table split by the \n separator:
| {"A/":"title1","B/":"item1"}" |
| "{"A/":"title2","B/":"item2"} |
Should we want the Title we will have to extract the title value via the Mid() function. To get the starting position we will use Find("A/",Value) which gives us the starting position of A/ {"A/":"title1"... However we don't want to use that as our starting point, want to skip the following characters: {"A/":"title1"... -> this gives us the 4+1, or simply +5
We will also have to define our stopping point, which is Find("B/",Value)-(Find("A/",Value)+8)
Here we take the index of the B character minus our index of A + 8 to get rid of the other characters:
{"A/":"title1","B/":"item1"}"
This leaves us with the actual A/ value (or title). Note: the last item (D/ is a bit different)
As you can probably tell, the new ParseJSON function makes our lives a lot easier so I would highly recommend trying that approach.
I hope this helps!