web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to set a condition...
Power Automate
Unanswered

How to set a condition based on the presence of an array

(0) ShareShare
ReportReport
Posted on by 170

I am creating a flow that pulls item information.  Sometimes the item will have an additional array, if it does, then I want the flow to grab a code from there and create a new item in a second system.  If it does not have the code, I'll give it a different name, and create the item.  

 

Essentially if "itemVariant" array = Null  is what I'd like to do.  Not really sure how to accomplish this though

 

{
    "type""object",
    "properties": {
        "statusCode": {
            "type""integer"
        },
        "headers": {
            "type""object",
            "properties": {
                "Transfer-Encoding": {
                    "type""string"
                },
                "Vary": {
                    "type""string"
                },
                "Access-Control-Allow-Headers": {
                    "type""string"
                },
                "Access-Control-Allow-Origin": {
                    "type""string"
                },
                "Access-Control-Allow-Credentials": {
                    "type""string"
                },
                "ms-correlation-x": {
                    "type""string"
                },
                "OData-Version": {
                    "type""string"
                },
                "Access-Control-Expose-Headers": {
                    "type""string"
                },
                "request-id": {
                    "type""string"
                },
                "x-content-type-options": {
                    "type""string"
                },
                "Strict-Transport-Security": {
                    "type""string"
                },
                "Date": {
                    "type""string"
                },
                "Server": {
                    "type""string"
                },
                "Content-Type": {
                    "type""string"
                },
                "Content-Length": {
                    "type""string"
                }
            }
        },
        "body": {
            "type""object",
            "properties": {
                "@@odata.context": {
                    "type""string"
                },
                "@@odata.etag": {
                    "type""string"
                },
                "id": {
                    "type""string"
                },
                "number": {
                    "type""string"
                },
                "displayName": {
                    "type""string"
                },
                "type": {
                    "type""string"
                },
                "itemCategoryId": {
                    "type""string"
                },
                "itemCategoryCode": {
                    "type""string"
                },
                "blocked": {
                    "type""boolean"
                },
                "gtin": {
                    "type""string"
                },
                "inventory": {
                    "type""integer"
                },
                "unitPrice": {
                    "type""integer"
                },
                "priceIncludesTax": {
                    "type""boolean"
                },
                "unitCost": {
                    "type""number"
                },
                "taxGroupId": {
                    "type""string"
                },
                "taxGroupCode": {
                    "type""string"
                },
                "baseUnitOfMeasureId": {
                    "type""string"
                },
                "baseUnitOfMeasureCode": {
                    "type""string"
                },
                "lastModifiedDateTime": {
                    "type""string"
                },
                "itemCategory": {
                    "type""object",
                    "properties": {
                        "@@odata.etag": {
                            "type""string"
                        },
                        "id": {
                            "type""string"
                        },
                        "code": {
                            "type""string"
                        },
                        "displayName": {
                            "type""string"
                        },
                        "lastModifiedDateTime": {
                            "type""string"
                        }
                    }
                },
                "defaultDimensions": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "@@odata.etag": {
                                "type""string"
                            },
                            "id": {
                                "type""string"
                            },
                            "parentType": {
                                "type""string"
                            },
                            "parentId": {
                                "type""string"
                            },
                            "dimensionId": {
                                "type""string"
                            },
                            "dimensionCode": {
                                "type""string"
                            },
                            "dimensionValueId": {
                                "type""string"
                            },
                            "dimensionValueCode": {
                                "type""string"
                            },
                            "postingValidation": {
                                "type""string"
                            }
                        },
                        "required": [
                            "@@odata.etag",
                            "id",
                            "parentType",
                            "parentId",
                            "dimensionId",
                            "dimensionCode",
                            "dimensionValueId",
                            "dimensionValueCode",
                            "postingValidation"
                        ]
                    }
                },
                "itemVariants": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "@@odata.etag": {
                                "type""string"
                            },
                            "id": {
                                "type""string"
                            },
                            "itemId": {
                                "type""string"
                            },
                            "itemNumber": {
                                "type""string"
                            },
                            "code": {
                                "type""string"
                            },
                            "description": {
                                "type""string"
                            }
                        },
                        "required": [
                            "@@odata.etag",
                            "id",
                            "itemId",
                            "itemNumber",
                            "code",
                            "description"
                        ]
                    }
                }
            }
        }
    }
}
Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,383 Most Valuable Professional on at

    Try using a length() function on the ItemVariantArray.  If the length is 0 then there are no records.  Just be sure an empty array is returned if there are no records.  Sometimes JSON will just not return fields that are null.

  • MaryT0905 Profile Picture
    170 on at

    Thank you for this! My Json is not returning anything because the fields are Null.  How do I work around this?

  • MaryT0905 Profile Picture
    170 on at
    Here is the schema for the parse I have
     
    {
        "type""object",
        "properties": {
            "statusCode": {
                "type""integer"
            },
            "headers": {
                "type""object",
                "properties": {
                    "Transfer-Encoding": {
                        "type""string"
                    },
                    "Vary": {
                        "type""string"
                    },
                    "Access-Control-Allow-Headers": {
                        "type""string"
                    },
                    "Access-Control-Allow-Origin": {
                        "type""string"
                    },
                    "Access-Control-Allow-Credentials": {
                        "type""string"
                    },
                    "ms-correlation-x": {
                        "type""string"
                    },
                    "OData-Version": {
                        "type""string"
                    },
                    "Access-Control-Expose-Headers": {
                        "type""string"
                    },
                    "request-id": {
                        "type""string"
                    },
                    "x-content-type-options": {
                        "type""string"
                    },
                    "Strict-Transport-Security": {
                        "type""string"
                    },
                    "Date": {
                        "type""string"
                    },
                    "Server": {
                        "type""string"
                    },
                    "Content-Type": {
                        "type""string"
                    },
                    "Content-Length": {
                        "type""string"
                    }
                }
            },
            "body": {
                "type""object",
                "properties": {
                    "@@odata.context": {
                        "type""string"
                    },
                    "@@odata.etag": {
                        "type""string"
                    },
                    "id": {
                        "type""string"
                    },
                    "number": {
                        "type""string"
                    },
                    "displayName": {
                        "type""string"
                    },
                    "type": {
                        "type""string"
                    },
                    "itemCategoryId": {
                        "type""string"
                    },
                    "itemCategoryCode": {
                        "type""string"
                    },
                    "blocked": {
                        "type""boolean"
                    },
                    "gtin": {
                        "type""string"
                    },
                    "inventory": {
                        "type""integer"
                    },
                    "unitPrice": {
                        "type""integer"
                    },
                    "priceIncludesTax": {
                        "type""boolean"
                    },
                    "unitCost": {
                        "type""number"
                    },
                    "taxGroupId": {
                        "type""string"
                    },
                    "taxGroupCode": {
                        "type""string"
                    },
                    "baseUnitOfMeasureId": {
                        "type""string"
                    },
                    "baseUnitOfMeasureCode": {
                        "type""string"
                    },
                    "lastModifiedDateTime": {
                        "type""string"
                    },
                    "itemCategory": {
                        "type""object",
                        "properties": {
                            "@@odata.etag": {
                                "type""string"
                            },
                            "id": {
                                "type""string"
                            },
                            "code": {
                                "type""string"
                            },
                            "displayName": {
                                "type""string"
                            },
                            "lastModifiedDateTime": {
                                "type""string"
                            }
                        }
                    },
                    "defaultDimensions": {
                        "type""array",
                        "items": {
                            "type""object",
                            "properties": {
                                "@@odata.etag": {
                                    "type""string"
                                },
                                "id": {
                                    "type""string"
                                },
                                "parentType": {
                                    "type""string"
                                },
                                "parentId": {
                                    "type""string"
                                },
                                "dimensionId": {
                                    "type""string"
                                },
                                "dimensionCode": {
                                    "type""string"
                                },
                                "dimensionValueId": {
                                    "type""string"
                                },
                                "dimensionValueCode": {
                                    "type""string"
                                },
                                "postingValidation": {
                                    "type""string"
                                }
                            },
                            "required": [
                                "@@odata.etag",
                                "id",
                                "parentType",
                                "parentId",
                                "dimensionId",
                                "dimensionCode",
                                "dimensionValueId",
                                "dimensionValueCode",
                                "postingValidation"
                            ]
                        }
                    },
                    "itemVariants": {
                        "type""array",
                        "items": {
                            "type""object",
                            "properties": {
                                "@@odata.etag": {
                                    "type""string"
                                },
                                "id": {
                                    "type""string"
                                },
                                "itemId": {
                                    "type""string"
                                },
                                "itemNumber": {
                                    "type""string"
                                },
                                "code": {
                                    "type""string"
                                },
                                "description": {
                                    "type""string"
                                }
                            },
                            "required": [
                                "@@odata.etag",
                                "id",
                                "itemId",
                                "itemNumber",
                                "code",
                                "description"
                            ]
                        }
                    }
                }
            }
        }
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 711

#2
Vish WR Profile Picture

Vish WR 691

#3
Haque Profile Picture

Haque 525

Last 30 days Overall leaderboard