i have a azure logic app. in a condition it checks for four payment methods 'Cash' 'Cheque' 'Credit Card' 'Transfer'. then it set to a variable in a following step. if it is not a payment method from above four it shows an error saying ' InvalidTemplate. The 'start index' for function 'substring' must be equal to or greater than zero and must be less than '1' which is the length of the string.https://aka.ms/logicexpressions#substring' and then the logic app fails. its okay even the payment method is incorrect the logic app should flow
Asked
Active
Viewed 122 times
0
-
Can you provide Flow design or code so that we can see where the problem for better understanding – RithwikBojja Jun 20 '23 at 05:56
-
So what do you want the outcome to be if it fails? – Skin Jun 20 '23 at 09:44
1 Answers
0
I have reproduced in my environment and got expected results as below:
Here I initialized a blank variable and then done by using below design.
Design:
Then:
Used True False in Conditions:
Code View:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@body('Parse_JSON')?['get']",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Compose"
},
"Condition": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "var",
"value": "Cash"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@outputs('Compose')",
"Cheque"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"CreditCard"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"Transfer"
]
}
}
]
},
"runAfter": {
"Compose": [
"Succeeded",
"Failed"
]
},
"type": "If"
},
"Condition_2": {
"actions": {
"Append_to_string_variable_2": {
"inputs": {
"name": "var",
"value": "Cheque"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@outputs('Compose')",
"Cash"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"CreditCard"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"Transfer"
]
}
}
]
},
"runAfter": {
"Compose": [
"Succeeded",
"Failed"
]
},
"type": "If"
},
"Condition_3": {
"actions": {
"Append_to_string_variable_3": {
"inputs": {
"name": "var",
"value": "CreditCard"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@outputs('Compose')",
"Cheque"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"Cash"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"Transfer"
]
}
}
]
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "If"
},
"Condition_4": {
"actions": {
"Append_to_string_variable_4": {
"inputs": {
"name": "var",
"value": "Transfer"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@outputs('Compose')",
"Cash"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"CreditCard"
]
}
},
{
"not": {
"equals": [
"@outputs('Compose')",
"Cheque"
]
}
}
]
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "If"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "var",
"type": "string"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"properties": {
"get": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
Output:
If Sent Transfer as below:
Output If sent CreditCard:
Output If sent Cash:
Output If sent Cheque:
Here used runAfter Failed Succeeded for conditions(inside conditions used append variable which was initialized empty at first) in design, you can clearly replicate using code( code view) and get to know what the functionality is.

RithwikBojja
- 5,069
- 2
- 3
- 7