Postscript (08/06/2019)
Since only String type data can be passed from PowerApps to Flow, I had to manually convert map data to String, but you added a function to convert JSON data to String!
Now you can easily pass data! Data source collections can now also be passed to Flow as data, making it extremely convenient!
See above article for details.
For reference, we have also updated the original article to use the new function.
Postscript (so far) Original article below
Since Microsoft PowerApps cannot be coded, PowerApps by itself can only display UI and screen transitions.
So, for more elaborate processing, we will call Microsoft Flow and have Flow do it for us.
In this case, the data is passed from PowerApps to Flow and the result data is returned from Flow to PowerApps, but the data that can be exchanged at that time is quite poor, as shown below.
- Only a pre-determined number of String data can be passed from PowerApps to Flow.
- Only one of the following data can be returned from Flow to PowerApps: Number, String, Bool, Date, File, and Mail, which are predetermined by Flow.
This is too difficult to use, so we have described a more creative way to pass Map data to Flow and return Array data.
Integration of PowerApps and Flow
The specifications for linking PowerApps and Flow are quite peculiar, so I will give a brief description.
- What kind of data Flow receives from PowerApps and what kind of data it returns must be determined on the Flow side before linking Flow and PowerApps.
- Flow can only receive a pre-determined number of String data from PowerApps
- String data that Flow receives from PowerApps is registered when
Check it out on PowerApps."
is clicked in the Flow GUI. - The order of String data arguments that Flow receives from PowerApps is the order in which you click
Check it out on PowerApps."
in the Flow GUI. - The order and number of String data arguments that Flow receives from PowerApps cannot be changed later.
- Flow responds to PowerApps with
[Action]-[PowerApps]-[Respond to PowerApps].
in Flow. - To link Flow and PowerApps, first create Flow, and then use
[Action]-[Flows]
in PowerApps. - When Flow and PowerApps are linked, the schema information of the data to be exchanged is passed from Flow to PowerApps.
- If the number of String data received by Flow is changed or the type of data returned from Flow to PowerApps is changed, the linkage between Flow and PowerApps must be broken and then reestablished, The schema information passed to PowerApps must be updated. If you do not update the schema information, an error will occur when calling Flow from PowerApps if the schema is different.
I don't think you understand what I'm talking about with all this, so I'll explain a little more...
For example, to add an argument for the String data that Flow receives on the Flow side, click Check it out on PowerApps."
where you want to use the String data.
Clicking "Check with PowerApps" three times will automatically create three String values, "Create Input," "Create Input 1," and "Create Input 2," as shown below, and assign them in order to the arguments that invoke Flow.
Flow call schema (in the order pressed)
To call this Flow from PowerApps, connect the PowerApps to the Flow, and from the PowerApps to the
<Flow名>.Run("test01", "test02", "test03")
Calls Flow with
The String argument set when calling Flow becomes the value received by Flow as it is.
Points to note
String arguments can only be registered by clicking on "Check with PowerApps" and once registeredIt cannot be deleted or reordered later........
This is so hard to use, but it's just a specification. ......
With the above specifications in mind, this is an explanation of how to pass Map data to Flow and return Array data.
How to pass Map data to Flow
The policy is that PowerApps has a function that converts JSON data to String, so the data to be sent is composed of JSON, which is then converted to String and sent to Flow.
Flow, on the other hand, has a function that creates JSON from String data, so the string data received from PowerApps is restored to JSON.
Flow accepts only one String data and assigns it to [Action]-[Data manipulation]-[Create].
through JSON() to extract the map.
Flow側
式
JSON(triggerBody()['test_入力'])
Example of Flow call on PowerApps side
Send text box values and collections as map data to Flow
式
<Flow名>.Run(JSON({item1:TextInput1.Text, item2:TextInput2.Text, table:tbl_test}))
editor
during execution
Flow side Called result
JSON data (map data) is restored on the Flow side.
How to return Array data from Flow to PowerApps
Normally, Flow responds to PowerApps with [Action]-[PowerApps]-[Respond to PowerApps].
, but this is done with [Action]-[Request]-[Response]
.
Then, any data type defined in the JSON schema of the response body can be returned to PowerApps.
However, PowerApps can only return "Basic data type" and "Table type (array of Map)" data types, so arbitrary JSON cannot be returned.
That is, it can only return either a single value of the basic data type or an array of Maps, such as [Map, Map, Map, ...].
Since returning a single value of the basic data type is the same as [Action]-[PowerApps]-[Respond to PowerApps].
, this section describes how to return a Map array.
procedure
For example,
[{col1:111, col2:"AAA"}, {col1:222, col2:"BBB"}]
Suppose you wanted to return data such as
Flow側
Put the following values in [Response]-[Show Advanced Options]-[Generate schema using sample payload].
[ {"col1":111, "col2":"AAA"} ]
Then a Yoshinari JSON schema is created.
Next, put the data you want to return in the "body" as a sample.
[ {"col1": 111, "col2": "AAA"}, {"col1": 222, "col2": "BBB"}, {"col1": 333, "col2": "CCC"} ]
PowerApps側
Flow returns an array of Maps, which are then stored as collection data on the PowerApps side.
ClearCollect('コレクション名', <Flow名>.Run(…))
Execution Result
The return value of the Flow is stored in the PowerApps collection (testCollection) and the data is displayed.
impressions
This is a bit aggressive, but now you can pass data from Power Apps to Flow as a map and return it as an array.
The integration between PowerApps and Flow is still in its developmental stages, and I have a feeling that the specifications in this area will likely change in the future, so I won't go any deeper...