azure-docs icon indicating copy to clipboard operation
azure-docs copied to clipboard

Null-ignore operator example is incorrect.

Open DTronD opened this issue 11 months ago • 1 comments

In the Operator section of the page, the following example is provided for the question mark operator (AKA null-ignoring operator):

@coalesce(trigger().outputs?.body?.<someProperty>, '')

Using the ? and the dot operators together creates a formula flagged as invalid when using the PowerApps formula editor. Can you confirm that that example is correct? I believe it should be:

@coalesce(trigger().outputs?body?<someProperty>, '')

Additionally, could you clarify (in the docs page) if the null-ignoring operator needs to be used at every "level" of the JSON object being referenced or does a higher-level usage also allow nulls at lower levels referenced?

E.g. given the object {"outputs" : { "body" : { "existingProperty" : "Levl3OfJSON" } }

Which of the following will work and not through a runtime error?:

  1. trigger().outputs?body.['someMissingProperty']

  2. trigger().outputs?body?['someMissingProperty']

  3. trigger().outputs.body?['someMissingProperty']

  4. trigger().outputs?body?['someMissingProperty']

  5. trigger().outputs?.body?.['someMissingProperty']

Finally, there is some debate in the PAuto forums on whether or not the null-ignore operator works when the object being referenced is an array instead of proper JSON object. If that is true could you provide clarification/details in the docs , please?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

DTronD avatar Mar 22 '24 21:03 DTronD

@DTronD Thanks for your feedback! We will investigate and update as appropriate.

Naveenommi-MSFT avatar Mar 23 '24 04:03 Naveenommi-MSFT

@DTronD, I'm checking with the product team about your question.

ecfan avatar Apr 16 '24 00:04 ecfan