onefox
onefox

Reputation: 177

How to set a variable to 'null' in a Azure Logic App?

I need to send null under a certain if case to a CRM Endpoint.

Since I need the value on multiple parts of the Logic App I would like to use a variable.

This code only set the variable to "" but not to null. I need the null in the case when the IC_CODE is not '05'.

"Set_variable_conditional_interchangability": {
              "type": "SetVariable",
              "inputs": {
                "name": "conditional_interchangability",
                "value": "@{if(equals(items('For_each')?['IC_CODE'], '05'), 928350000, null)}"
              },
              "runAfter": {
                "Set_variable_direction": [
                  "Succeeded"
                ]
              }
            }

Upvotes: 1

Views: 4100

Answers (1)

Paco de la Cruz
Paco de la Cruz

Reputation: 2154

Because you are using curly braces {} in the value, the runtime is converting the null value to an empty string.

Try this:

"Set_variable_conditional_interchangability": {
              "type": "SetVariable",
              "inputs": {
                "name": "conditional_interchangability",
                "value": "@if(equals(items('For_each')?['IC_CODE'], '05'), 928350000, null)"
              },
              "runAfter": {
                "Set_variable_direction": [
                  "Succeeded"
                ]
              }
            }

HTH

Upvotes: 3

Related Questions