cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fsim
Helper II
Helper II

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

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

1 ACCEPTED SOLUTION

Accepted Solutions
manuelstgomes
Community Champion
Community Champion

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.

View solution in original post

6 REPLIES 6
manuelstgomes
Community Champion
Community Champion

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.

@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
Community Champion
Community Champion

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
Helper II
Helper II

@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 !

 

 

manuelstgomes
Community Champion
Community Champion

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.

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,516)