Power Automate: Complete Flow Example - NovaGL/coupa-resources GitHub Wiki

Complete Flow Example

Now that we have a few API’s setup lets try it out in Power Automate.

Create a copy of Addresses - Create Address and change the Method to Get and name it as Addresses - Get Addresses

My Flows > new flow > Instant cloud flow

Choose Manually trigger a flow and create

Before we get into calling the API we need to do some preparation work

Create (initialize) the following variables

Name Type Value Step Name
Offset Integer 0 Offset
Count Integer 50 Item count
Results Array Item Results

Now to get all the addresses we want to loop the API results until the count of the records is under 50.

Create a (Do Until) step

Variable Name Function Value Step Name
Count Is less than 50 Get all Addresses

Call Coupa API

Inside the Do Until Loop click Add Action and select Addresses - Get Addresses

Limit Offset dir Return object
Count Offset (variable) Shallow (or as required)

Set Variables

Now we want to increment the variable so the loop works

Name Type Value (expression) Step Name
Offset Increment Variable length(body('Addresses_-_Get_Addresses')) Increment Offset
Count Set Variable length(body('Addresses_-_Get_Addresses')) Result Count

To make sure we are not adding empty results to our output we check if the API returned any results

Checking for empty results

Create an IF step

Variable Name Function Value Step Name
Count Is greater than 0 Results Found

Store results

Now create a Select step so we can store the results in. Maybe sure this is set in If Yes

From Body
Map Name Map Value
Id Id
Street1 street1
Street2 Street2
city city
State State
Postcode Postcode
location-code location-code
name name

Merge results

Let’s add the current results to the exiting results

Create a Compose step to temporarily store it

Inputs Expression
Count union(variables('results'),body('Select'))

Update results array

Now lets move the results to the results variable

Name Type Value
Results Set Variable Outputs(‘compose’)

View Results

Now outside the loop create a new compose element so we can see the results

Name Type Value
Results Compose Results