Here is a full working example of using "condition"
action
Notice that I added only 2 conditions but you can add one for each company that you have
The app run each day and in each execution I check as many conditions as I want. In my case I check of the day of the week
is one then I execute the task - in my case the task is to add row to sql server table
I also added condition to check of the day of the week
is more than 3 and in this case i add the value to the table
Here is the full code:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Condition": {
"actions": {
"Insert_row_(V2)_2": {
"inputs": {
"body": {
"c": 1
},
"host": {
"connection": {
"name": "@parameters('$connections')['sql']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[TableName]'))}/items"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": {
"and": [
{
"equals": [
"@variables('MyDay')",
1
]
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "If"
},
"Condition_2": {
"actions": {
"Insert_row_(V2)_3": {
"inputs": {
"body": {
"c": "@variables('MyDay')"
},
"host": {
"connection": {
"name": "@parameters('$connections')['sql']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[TableName]'))}/items"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": {
"and": [
{
"greater": [
"@variables('MyDay')",
3
]
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "If"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "MyDay",
"type": "integer",
"value": "@int(dayOfWeek(utcNow()))"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Second",
"interval": 20,
"timeZone": "Israel Standard Time"
},
"recurrence": {
"frequency": "Second",
"interval": 20,
"timeZone": "Israel Standard Time"
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"sql": {
"connectionId": "/subscriptions/9be5b21d-3676-40f1-baec-16c10ae909ec/resourceGroups/qq/providers/Microsoft.Web/connections/sql-1",
"connectionName": "sql-1",
"id": "/subscriptions/9be5b21d-3676-40f1-baec-16c10ae909ec/providers/Microsoft.Web/locations/centralus/managedApis/sql"
}
}
}
}
}