Logic App Std For Each Loop Changing Valid true boolean to Invalid True

Warren Kinley 61 Reputation points
2022-12-16T10:29:05.67+00:00

I have a simple Logic App standard workflow:
271374-image.png

A boolean value retrieved from the table is the valid JSON values true/false, until within the "For each" loop, where it becomes True/False - invalid JSON.

  • [Output] Get resubmission details = "Resubmission": true,
  • [Output] Parse table entries = "Resubmission": true,
  • [Input] For each resubmission entry... = "Resubmission": True,

Is this a Logic App bug or a misunderstanding?

I have now discovered where the issue lays. When the workflow is initially deployed via devops the run fails since the "Compose" action does not recognise that the input is json, the designer shows the input not formatted and in black text:
272820-image.png

I added a space to the "Compose" action and updated in the portal designer, now I see that the input to the action is now valid json (beautified):
272834-image.png

What is wrong when the deployment occurs?

It seems the deployment code view includes the escaped characters:

{  
    "inputs": "{\n  \"Resolution\": \"@{items('For_each_resubmission_entry_on_table')?['Resolution']}\",\n  \"Resubmission\": @{items('For_each_resubmission_entry_on_table')?['Resubmission']},\n  \"SourceSystem\": \"@{items('For_each_resubmission_entry_on_table')?['SourceSystem']}\",\n  \"ValueType\": \"@{items('For_each_resubmission_entry_on_table')?['ValueType']}\",\n  \"DestinationSystem\": \"@{items('For_each_resubmission_entry_on_table')?['DestinationSystem']}\",\n  \"TimeUnit\": \"HOUR\",\n  \"StartTimeOffset\": @{items('For_each_resubmission_entry_on_table')?['StartTimeOffset']},\n  \"StopTimeOffset\": @{items('For_each_resubmission_entry_on_table')?['StopTimeOffset']}\n}"  
}  

And once an arbitrary update in the portal is done:

{  
    "inputs": {  
        "DestinationSystem": "@{items('For_each_resubmission_entry_on_table')?['DestinationSystem']}",  
        "Resolution": "@{items('For_each_resubmission_entry_on_table')?['Resolution']}",  
        "Resubmission": "@items('For_each_resubmission_entry_on_table')?['Resubmission']",  
        "SourceSystem": "@{items('For_each_resubmission_entry_on_table')?['SourceSystem']}",  
        "StartTimeOffset": "@items('For_each_resubmission_entry_on_table')?['StartTimeOffset']",  
        "StopTimeOffset": "@items('For_each_resubmission_entry_on_table')?['StopTimeOffset']",  
        "TimeUnit": "HOUR",  
        "ValueType": "@{items('For_each_resubmission_entry_on_table')?['ValueType']}"  
    }  
}  
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2022-12-19T13:57:14.98+00:00

    @Anonymous Thanks for sharing the details. I am not sure why you are again doing Parse JSON inside the for each loop. The value is already tokenized, and it should be available inside your foreach. Whatever schema that you have defined in your Parse JSON action the tokenized field will be changed accordingly. I have used the below schema in my Parse JSON action and define
    Resubmission of type boolean. I am defining the entities value to my parse JSON.

    {  
        "items": {  
            "properties": {  
                "DestinationSystem": {  
                    "type": "string"  
                },  
                "PartitionKey": {  
                    "type": "string"  
                },  
                "Resolution": {  
                    "type": "string"  
                },  
                "Resubmission": {  
                    "type": "boolean"  
                },  
                "RowKey": {  
                    "type": "string"  
                },  
                "SourceSystem": {  
                    "type": "string"  
                },  
                "StartTimeOffset": {  
                    "type": "integer"  
                },  
                "StopTimeOffset": {  
                    "type": "integer"  
                },  
                "Timestamp": {  
                    "type": "string"  
                },  
                "ValueType": {  
                    "type": "string"  
                },  
                "odata.etag": {  
                    "type": "string"  
                }  
            },  
            "required": [  
                "DestinationSystem",  
                "PartitionKey",  
                "Resolution",  
                "Resubmission",  
                "RowKey",  
                "SourceSystem",  
                "StartTimeOffset",  
                "StopTimeOffset",  
                "Timestamp",  
                "ValueType",  
                "odata.etag"  
            ],  
            "type": "object"  
        },  
        "type": "array"  
    }  
    

    272163-image.png

    The output is parsed as per my schema that I have defined in my outside and inside the loop Parse JSON action. Please validate the schema at your end and if you still observe the issue then please share your schema.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Warren Kinley 61 Reputation points
    2022-12-19T14:05:43.003+00:00

    Hi, for some reason I cannot comment against your answer... I am not doing a parse json inside my foreach loop, only a "Compose" then an "AppendToStringVariable":

    "actions": {  
                        "Add_resubmission_to_request_body": {  
                            "inputs": {  
                                "name": "ResubmissionRequestBody",  
                                "value": "@concat(outputs('Generate_request_from_table_entity'),',')"  
                            },  
                            "runAfter": {  
                                "Generate_request_from_table_entity": [  
                                    "Succeeded"  
                                ]  
                            },  
                            "type": "AppendToStringVariable"  
                        },  
                        "Generate_request_from_table_entity": {  
                            "inputs": "{\n  \"Resolution\": \"@{items('For_each_resubmission_entry_on_table')?['Resolution']}\",\n  \"Resubmission\": @{items('For_each_resubmission_entry_on_table')?['Resubmission']},\n  \"SourceSystem\": \"@{items('For_each_resubmission_entry_on_table')?['SourceSystem']}\",\n  \"ValueType\": \"@{items('For_each_resubmission_entry_on_table')?['ValueType']}\",\n  \"DestinationSystem\": \"@{items('For_each_resubmission_entry_on_table')?['DestinationSystem']}\",\n  \"TimeUnit\": \"HOUR\",\n  \"StartTimeOffset\": @{items('For_each_resubmission_entry_on_table')?['StartTimeOffset']},\n  \"StopTimeOffset\": @{items('For_each_resubmission_entry_on_table')?['StopTimeOffset']}\n}",  
                            "runAfter": {},  
                            "type": "Compose"  
                        }  
                    }  
    
    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.