Reputation: 51
I'm newbie into Logic App. And I'm rarely stragling with some basics of it. Especially, when it comes to manipulation/selecting data.
So, i have a problem with checking if key is present in collection. Have this variable:
"Initialize_ReportType_Variable": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ReportTypeCollection",
"type": "Array",
"value": "@parameters('reportType')"
}
]
},
"runAfter": {
"Initialize_GAIMFunds": [
"SUCCEEDED"
]
}
}
It returns me output of array:
[
{
"FundKey": "1",
"FundName": "s1",
"ReportGroup": "A",
"StoreProcedure": "SP_1"
},
{
"FundKey": "2",
"FundName": "s2",
"ReportGroup": "B",
"StoreProcedure": "SP_2"
}
]
then there are like output of variable Process_Filtered_Output:
{
"FilteredResults": [
{
"ProcessID": 1,
"ProcessName": "A1",
"ImportID": 1,
"ImportName": "I1",
"WorkspaceName": "A",
"WorkspaceID": "8a",
"ModelID": "58B4",
"ModelName": "M1",
"ReportType": 1
}
]
}
I just need to check if there is an ReportType = FundKey in Initialize_ReportType_Variable by Process_Filtered_Output.ReportType
Please help me to figure out how can it be resolved. I've tried with bunch of approaches like For_Each, but i can't even to write it normal without errors.
Upvotes: 0
Views: 49
Reputation: 6497
I have used the below given workflow to get the results by comparing FundKey with ReportType using Filter array.
Code :-
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"ReportTypeCollection": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ReportTypeCollection",
"type": "array",
"value": [
{
"FundKey": "1",
"FundName": "s1",
"ReportGroup": "A",
"StoreProcedure": "SP_1"
},
{
"FundKey": "2",
"FundName": "s2",
"ReportGroup": "B",
"StoreProcedure": "SP_2"
}
]
}
]
},
"runAfter": {}
},
"Process_Filtered_Output": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Process_Filtered_Output",
"type": "object",
"value": {
"FilteredResults": [
{
"ProcessID": 1,
"ProcessName": "A1",
"ImportID": 1,
"ImportName": "I1",
"WorkspaceName": "A",
"WorkspaceID": "8a",
"ModelID": "58B4",
"ModelName": "M1",
"ReportType": 1
}
]
}
}
]
},
"runAfter": {
"Parse_JSON": [
"SUCCEEDED"
]
}
},
"Parse_JSON": {
"type": "ParseJson",
"inputs": {
"content": "@variables('ReportTypeCollection')",
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"FundKey": {
"type": "string"
},
"FundName": {
"type": "string"
},
"ReportGroup": {
"type": "string"
},
"StoreProcedure": {
"type": "string"
}
},
"required": [
"FundKey",
"FundName",
"ReportGroup",
"StoreProcedure"
]
}
}
},
"runAfter": {
"ReportTypeCollection": [
"SUCCEEDED"
]
}
},
"Filter_array": {
"type": "Query",
"inputs": {
"from": "@body('Parse_JSON')",
"where": "@equals(item()['FundKey'],string(variables('Process_Filtered_Output')?['FilteredResults']?[0]['ReportType']))"
},
"runAfter": {
"Process_Filtered_Output": [
"SUCCEEDED"
]
}
},
"Compose": {
"type": "Compose",
"inputs": "@body('Filter_array')",
"runAfter": {
"Filter_array": [
"SUCCEEDED"
]
}
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_a_HTTP_request_is_received": {
"type": "Request",
"kind": "Http"
}
}
},
"kind": "Stateful"
}
Please note, you might get no outputs in Filter Array action post executing the workflow. To see the actual output click on show raw outputs.
Its a known issue and as per github ticket, this has been fixed but looks like its still occurs.
You can add Compose action to get the actual output of Filter Array action alike me.
Upvotes: 0