Marcel Lehmann

learn and find tipps & tricks around the powerplatform

Trigger a flow only once without premium? Yes, you can lock a flow temporarily.

Photo by Karolina Grabowska on Pexels.com

Examples
Overview Total Flow
Preparation
Structure of the flow
Flow-Code to copy

IMPORTANT Update 2022-12-14:
I’ve tested this solution again, and it doesn’t work anymore without a trial or premium license for Dataverse.


Maybe the title seems a bit strange to you, but I would like to show you how to trigger a flow only once every X minutes.

There is a function ‘Concurrency Control’ which ensures that the flow can be executed in parallel only X times (here on the picture I have set 1 time).

The disadvantage of this setting is that if i still try to start the flow, all flow runs will be queued and executed one after the other.

In my example i show you how the flow is only executed completely every X minutes (depending on the setting) and does not perform your actions in the meantime.

I tested this variant with a ‘PowerAutomate Free’ user to make sure that the DataVerse connection used here in the solution is really usable without Premium.

Thanks also to Ludovic Perrichon and his blog post ‘Set Environment Variables with PowerAutomate‘ where I was able to get some tips.

Examples to use

  1. You want to start a DataFlow to synchronize data from powerapps only every certain interval and when it is needed..
  2. You want to send error mails only once and not every time the error occurs.
  3. You want to update the DataSet of PowerBI only every certain interval and when it is needed. (e.g. Trigger via Mail or PowerApps)

Overview Total Flow

Preparation

First create an environment variable. We will use this later during a flow-run to ‘Check-In’ (in our case 1), if this is the only active flow. At the end of a flow-run this flow will be set back to the status ‘Check-Out’ (in our case 0).

Structure of the flow

  1. Enter the InternalName (incl. prefix)
  2. In the condition we check if a flow has already set the environment variable to status ‘Check-In’ (here 1).
  3. Here we refer to the environment variable we inserted under 1. and retrieve it in the corresponding dataverse table.

    Then we write the value 1 into it (here our ‘check-in’)

  4. Under YOUR FLOW RUN you can add your own actions. So build your own flow as usual.
  5. In the last step we set again the environment variable to 0 (‘Check-Out’)











Flow-Code to copy

{"id":"6a710bec-59b5-41e2-9d66-522828bc1a1d","brandColor":"#8C3900","connectionReferences":{"shared_commondataserviceforapps_1":{"connection":{"id":"/new_crDataVerse"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Trigger_a_flow_only_once","operationDefinition":{"type":"Scope","actions":{"Initalitation":{"type":"Scope","actions":{"EnvironmentVariable_InternalName":{"type":"Compose","inputs":"new_evCurrentFlowRun","runAfter":{},"metadata":{"operationMetadataId":"e7863b68-180c-4a90-9ce8-c10dcefa3243"}},"Next_time_run_in_..._minutes":{"type":"Compose","inputs":1,"runAfter":{"EnvironmentVariable_InternalName":["Succeeded"]},"metadata":{"operationMetadataId":"226a23bb-1135-4353-9665-356b57fc74a9"}}},"runAfter":{},"metadata":{"operationMetadataId":"69ee8a97-af1f-4a67-8fd5-a7e599085717"}},"Condition":{"type":"If","expression":{"equals":["@parameters('ev CurrentFlowRun (new_evCurrentFlowRun)')","@string('0')"]},"actions":{"CheckIn_EnvironmentVariable":{"type":"Scope","actions":{"List_rows":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps_1","operationId":"ListRecords","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"environmentvariabledefinitions","$filter":"schemaname eq '@{outputs('EnvironmentVariable_InternalName')}'"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{},"metadata":{"operationMetadataId":"03ece656-fbd2-4b03-8108-a3e410ca8af6"}},"Update_a_row":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps_1","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"environmentvariabledefinitions","recordId":"@first(outputs('List_rows')?['body/value'])?['environmentvariabledefinitionid']","item/defaultvalue":"1"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"List_rows":["Succeeded"]},"metadata":{"operationMetadataId":"bafd5564-fcc7-4dd5-8db9-24770f9abd12"}}},"runAfter":{},"metadata":{"operationMetadataId":"0e6a1572-f9aa-460c-8bc0-62d2b211d7a4"}},"YOUR_FLOW_RUN":{"type":"Scope","actions":{},"runAfter":{"CheckIn_EnvironmentVariable":["Succeeded"]},"metadata":{"operationMetadataId":"07812991-d984-4cd2-963a-6cf3c33a2760"}},"CheckOut_EnvironmentVariable":{"type":"Scope","actions":{"Delay_to_reset_EnvironmentVariable":{"type":"Wait","inputs":{"interval":{"count":"@outputs('Next_time_run_in_..._minutes')","unit":"Minute"}},"runAfter":{},"metadata":{"operationMetadataId":"433a9fec-2212-4a2e-a662-6ee05709d41d"}},"Update_a_row_2":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps_1","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"environmentvariabledefinitions","recordId":"@first(outputs('List_rows')?['body/value'])?['environmentvariabledefinitionid']","item/defaultvalue":"0"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Delay_to_reset_EnvironmentVariable":["Succeeded"]},"metadata":{"operationMetadataId":"cda37d9a-9b1c-4565-b8a2-47086da28702"}}},"runAfter":{"YOUR_FLOW_RUN":["Succeeded","Failed","TimedOut"]},"metadata":{"operationMetadataId":"67d1627a-e2b3-4d8e-9d65-994809442d32"}}},"runAfter":{"Initalitation":["Succeeded"]},"metadata":{"operationMetadataId":"1f9b31db-6d78-46ab-af7f-7b004a375f62"}}},"runAfter":{},"metadata":{"operationMetadataId":"1b5d9a0a-3223-45df-b9d3-afe6eedf8a3b"}}}

Published by

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: