Share
Embed
Transcript
35 slides
-
Agenda 1. What is an array? 2. Handle arrays with
Power Automate -Basic 3. Handle arrays with Power Automate -Practical use 4. Handle arrays with Power Automate -Function -
I'm making a game with Power Automate and Power Virtual
Agents ⚫ Othello ⚫ Concentration ⚫ Animal shogi ➢ Array manipulation required -
Reference site ▪ JSONと仲良くなるために (まとめ) https://mofumofupower.hatenablog.com/entry/2020/09/04/190039 ▪ Apply to each
のパフォーマンス改善 (配列加工の場合) https://mofumofupower.hatenablog.com/entry/2020/08/12/093000 ▪ Power Automateの裏側をみてみよう! (1/2) https://qiita.com/h-nagao/items/be565fdac60a9b2968d5 ▪ Power Automateの裏側をみてみよう (2/2) https://qiita.com/h-nagao/items/4f590a6e3b21ea669d0d -
What is an array? ① • A number of variables
(boxes for storing values) connected together. • Each box is called an "element" of the array. • Each element of the array is assigned a number called "index". • In Power Automate, subscripts are counted from 0. variable 0 1 2 3 4 5 -
What is an array? ② • In an array It
can only handle values of the same type. Only values of the same nature should be included. • Enclose the data in brackets, and separate each item (element) with a comma (JSON) • When retrieving data, specify the subscript. (how many data items) • Powe Automate can interpret strings as a sequence of individual characters (=array). [ 1, 3, 2, 4, 0, 2 ] -
Practice ➀ ➀Create an array containing the following values (In
JSON format) • Voorhees • Bourne • Statham ["Voorhees", "Bourne", "Statham"] [ "Voorhees", "Bourne", "Statham“ ] -
Create an array ▪ [Data Operation] – [Compose] ▪ [Initialize
variable] ⇒ Array ▪ Function ⇒ array() createArray() range() split() etc. -
Referencing an array ▪ Extracting a single element from an
array① outputs(‘Action Name’)?[0] ➢ Specify by index When specifying subscripts, do not enclose them in [ ’ ](single quotation marks) -
Referencing an array ▪ Extracting a single element from an
array② first() ➢ Get the first element last() ➢ Get the last element -
Referencing an array ▪ Extract multiple elements from an array
➢ Apply to each Item() is acceptable -
What is an array? ③ arms guard ▪ Oh... Crystal
Lake JSON panda man Crystal Lake JSON panda girl Crystal Lake JSON panda boy N.Y. JSON panda woman 研究所 JSON panda Taro space ship JSON panda destinati on -
What is an array? ④ • Each element can also
be specified as an object or array [ {"destination": {"address":"Crystal Lake","name":"JSON panda man"}, "arms": {"axe":1,"chainsaw":3}, "guard": {"mask":1} }, {"destination": {"address":"Crystal Lake","name":"JSON panda Girl"}, "arms": {"axe":2,"chainsaw":1}, "guard": {"mask":3} }, ---- omitting the middle part--- {"destination": {"address":"space ship","name":"JSON panda"}, "arms": {"axe":1,"chainsaw":0}, "guard": {"mask":2} } ] [ [1,2,3], [4,5,6,7], [8,9] ] -
Create an array - Practical use ▪ [Data Operation] –
[Compose] ▪ [Initialize variable] ⇒ Array ▪ Function ⇒ array() createArray() -
Create an array - Practical use ▪ Extracting a single
element from an array① 1. JSON Pretty Linter (https://lab.syncer.jp/Tool/JSON-Viewer/) reference「気ままに勉強会 #6 JSONについて」 https://speakerdeck.com/miyakemito/jsonhabu-kunai outputs(‘Action Name’)?[0]?[‘destination’]?[‘name’] ➢ Specify by index -
Create an array - Practical use ▪ Extract multiple elements
from an array ➢ Apply to each -
Create an array - Practical use Apply to each is
a slow process. The execution speed of Apply to each is very slow. There are times when this must be tolerated, but there are also times when it can be avoided. -
Create an array - Practical use Avoid Apply to each
◼ The number of repetitions is fixed. ➢ Line up the actions for the number of loops. ➢ The "how many times" is specified by the index. -
Create an array - Practical use Avoid Apply to each
◼ Use an action that includes loop processing ➢ [Data Operation] • Handle only the value of each element • Create CSV table …etc. ➢ Actions that can interpret the array 「リスト形式のデータを Adaptive Cards で表示する方法」 https://mofumofupower.hatenablog.com/entry/2020/07/27/153632 …etc. -
Create an array - Practical use ▪ Extract multiple elements
from an array without using Apply to each ➢ [Select] item()?[‘destination’]?[‘name'] -
Create an array - Practical use ➢ [Select] item()?[‘slice‘] item()?[‘fish
served whole‘] concat(item()?[‘slice‘], ‘rice scoop‘) ▪ Extract multiple elements from an array without using Apply to each -
Create an array - Practical use ➢ [Fiter array] item()?[‘guard’]?[‘mask']
▪ Extract multiple elements from an array without using Apply to each -
Create an array - Practical use ➢ [Filter array] ▪
Extract multiple elements from an array without using Apply to each -
Create an array - Practical use ➢ Apply to each
▪ Extract multiple elements from an array without using Apply to each -
Create an array - Practical use ➢ [Join] “JSON panda
man,JSON panda Girl, JSON panda boy,JSON JSON panda woman, JSON panda Taro,JSON panda" ▪ Extract multiple elements from an array without using Apply to each -
Create an array - Practical use ➢ [Create CSV table]
name,mask JSON panda man,1 JSON panda Girl,3 JSON panda boy,2 JSON panda woman,4 JSON panda Taro,0 JSON panda,2 ▪ Extract multiple elements from an array without using Apply to each -
Array Manipulation with Power Automate Function ➢ If you have
any requests • Contains() • empty () • union () • intersection () • Item () • Length () • setProperty () ・・・etc -
Summary Arrays are useful Controlling Arrays Makes Power Automate More
Fun Use arrays to create interesting flows!