Reference Logic App parameter name

Noah Van Loen 61 Reputation points
2020-10-09T19:11:20.41+00:00

I would like to get the reference to the parameter name, as well as its value, within a Logic App. So, given:

    "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            },
            "username": {
                "defaultValue": "ABCDE",
                "type": "String"
            }
        },

I would like to be able to do something like @{concat(parameters('username')['name'],'=',parameters('username'))} to get a string like "username=ABCDE".

Perhaps this is easy with the right syntax? Apologies but didn't see this in the docs.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,080 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 25,691 Reputation points Microsoft Employee
    2020-10-13T00:23:49.71+00:00

    Hello @Noah Van Loen , I have the following flow in my logic app, which I used to get the desired output.
    I used a HTTP request trigger, with the schema provided above as "Request Body JSON Schema"
    31818-image.png

    I then used the "Parse JSON" action, with the request body above as the content. ( You can choose any Dynamic content as shown below, just make sure to upload the appropriate schema.)
    31841-parsejson.jpg

    As as a response body, I used the "concat" function for the Parsed JSON above. You can select the "concat" expression from "Expression tab" and then from the "Dynamic Content" you can select the objects from the Parsed JSON.
    31842-concat.jpg

    The concat expression I achieved based on JSON payload generated by the schema provided is @concat('username','=', body('Parse_JSON')?['parameters']?['username']?['defaultValue']).
    Please let me know if there are any additional concerns, I will be glad to continue with our discussion.

    1 person found this answer helpful.

  2. ChaitanyaNaykodi-MSFT 25,691 Reputation points Microsoft Employee
    2020-10-12T05:16:37.84+00:00

    Hello @Noah Van Loen , You can use Parse JSON action to concat the required fields. The expression obtained should be similar as below

    "@markus.bohland@hotmail.de (body('Parse_JSON')?['username']?['name'],'=',body('Parse_JSON')?['username'])",

    Please let me know if this does not resolve your issue, I will be happy to continue with our discussion.

    0 comments No comments

  3. Noah Van Loen 61 Reputation points
    2020-10-12T23:00:23.267+00:00

    Thanks @ChaitanyaNaykodi-MSFT . What is the syntax to use Parse_JSON to parse the parameter list? Schema=

        {  
          "type": "object",  
          "properties": {  
            "parameters": {  
              "type": "object",  
              "properties": {  
                "$connections": {  
                  "type": "object",  
                  "properties": {  
                    "defaultValue": {  
                      "type": "object"  
                    },  
                    "type": {  
                      "type": "string"  
                    }  
                  }  
                },  
                "username": {  
                  "type": "object",  
                  "properties": {  
                    "defaultValue": {  
                      "type": "string"  
                    },  
                    "type": {  
                      "type": "string"  
                    }  
                  }  
                }  
              }  
            }  
          }  
        }  
    

    How to reference the parameters as input to Parse_JSON? If I pass in "parameters('username'), I get "ABCDE", not the JSON structure.

    0 comments No comments

  4. ChaitanyaNaykodi-MSFT 25,691 Reputation points Microsoft Employee
    2020-10-14T23:23:19.48+00:00

    Hello @Noah Van Loen , I am sorry for the delay, I could not find a straight forward functionality to achieve the above requirement. I was able to find a work-around by using some of the inbuilt string operations. After performing the "Parse Json" I initialized a variable. Where I converted Parameters property to string and used split operation to get the "username" parameter name as shown below.

    split(split(string(body('Parse_JSON')?['parameters']),',')2,':')[0]

    The split property generates an array, and you can select any property name as required (You can also use 'Replace' just incase if required.). Then I performed concat operation as shown below.

    concat(variables('parameterName'),'=',string(body('Parse_JSON')?['parameters']?['username']?['defaultValue']))

    32270-initializevariable.jpg

    I understand that the above work-around is complex. Another option is to link a function app to your logic app to perform the required operations using code. Please let me know if you have any additional concerns.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.