Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Handling Arrays in Power Automate (1)

MiyakeMito
February 20, 2022

Handling Arrays in Power Automate (1)

MiyakeMito

February 20, 2022
Tweet

More Decks by MiyakeMito

Other Decks in Technology

Transcript

  1. Array in Power Automate 気ままに勉強会 #08

  2. Today's goal Let's master the array

  3. 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
  4. Miyake Mito https://www.icsoft.jp/ @MiTo60448639 https://qiita.com/MiyakeMito

  5. I'm making a game with Power Automate and Power Virtual

    Agents ⚫ Othello ⚫ Concentration ⚫ Animal shogi ➢ Array manipulation required
  6. 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
  7. What is an array?

  8. 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
  9. 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 ]
  10. Practice ➀ ➀Create an array containing the following values (In

    JSON format) • Voorhees • Bourne • Statham ["Voorhees", "Bourne", "Statham"] [ "Voorhees", "Bourne", "Statham“ ]
  11. Handle arrays with Power Automate Basic

  12. Create an array ▪ [Data Operation] – [Compose] ▪ [Initialize

    variable] ⇒ Array ▪ Function ⇒ array() createArray() range() split() etc.
  13. 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)
  14. Referencing an array ▪ Extracting a single element from an

    array② first() ➢ Get the first element last() ➢ Get the last element
  15. Referencing an array ▪ Extract multiple elements from an array

    ➢ Apply to each Item() is acceptable
  16. Handle arrays with Power Automate Practical use

  17. 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
  18. 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] ]
  19. Create an array - Practical use ▪ [Data Operation] –

    [Compose] ▪ [Initialize variable] ⇒ Array ▪ Function ⇒ array() createArray()
  20. 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
  21. Create an array - Practical use ▪ Extract multiple elements

    from an array ➢ Apply to each
  22. 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.
  23. 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.
  24. 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.
  25. Create an array - Practical use ▪ Extract multiple elements

    from an array without using Apply to each ➢ [Select] item()?[‘destination’]?[‘name']
  26. 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
  27. Create an array - Practical use ➢ [Fiter array] item()?[‘guard’]?[‘mask']

    ▪ Extract multiple elements from an array without using Apply to each
  28. Create an array - Practical use ➢ [Filter array] ▪

    Extract multiple elements from an array without using Apply to each
  29. Create an array - Practical use ➢ Apply to each

    ▪ Extract multiple elements from an array without using Apply to each
  30. 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
  31. 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
  32. Handle arrays with Power Automate Function

  33. Array Manipulation with Power Automate Function ➢ If you have

    any requests • Contains() • empty () • union () • intersection () • Item () • Length () • setProperty () ・・・etc
  34. Summary Arrays are useful Controlling Arrays Makes Power Automate More

    Fun Use arrays to create interesting flows!
  35. Thank you very much.