Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

for a selected file trigger and empty value with non existing variable in json

(0) ShareShare
ReportReport
Posted on by 75

Hi there !

 

So I built a low using this trigger. it's an approval flow, so I request an approver, a comment, a couple of date. The caller can also fill in an optional email  account who should be aware of the approval. 
Then, in the flow I update the Sharepoint library with the data the user filled in. 

Unfortunatelly, If the optional email is left blank, it generate an error. "Bad template. email2 variable don't exist..." (see picture below)

In fact the trigger do not create an internal Variable in the JSON for the non filled-in fields.

 

How can I manage this ? How can I test if the user filled in a field ? Because as soon as I try to refer to it, if it's empty, it failed the flow.


output.pngerror_flow.png

  • fsim Profile Picture
    75 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    for those hwo might come here:
    be aware that  if(empty(triggerBody()['Email_1']),null,triggerBody()['Email_1']) don't work ! Same error than above. You need to use the conditional branch

  • manuelstgomes Profile Picture
    6,625 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    HI @fsim 

     

    Yeah that works also. Glad it's working.

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • fsim Profile Picture
    75 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    @manuelstgomes 

    indeed the  empty () function did not crash the flow despite the email_2 did not exist !
    So I'm good to create 1 variable per field, and update these variable with the value of the fields when they are filled in and with blank() when they are not. 
    Then I will use those new variables in my update.

    right ?

    Or is it a way to put this test directly in the update item ? 

     

    Thanks anyway !

     

     

  • Verified answer
    manuelstgomes Profile Picture
    6,625 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    HI @fsim 

     

    Makes sense. Let's try the following. Create a condition where the left side you have the following formula:

    empty(triggerBody()?['email_2'])

    and in the right equals to true.

     

    Can you please check if and let me know if you have any questions?

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • fsim Profile Picture
    75 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    @manuelstgomes thanks for your answer

    That's exactly my point: Email_2 will only be in the json if the user filled in the "optional Email" field.

    So I need to check prior the update if the email box was filled or not.

     

  • manuelstgomes Profile Picture
    6,625 on at
    Re: for a selected file trigger and empty value with non existing variable in json

    Hi @fsim 

     

    Somewhere in the "Update file properties 4" you have a "email_2", but if you look at the JSON there is no field with that name. Do you mean "email_1"?

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >