cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rinceward
Level: Powered On

I need an Update if Else?

Hi All

 

I am very new to PowerApps but I am also finding it great to work with most of the time.

 

I have nearly created a guest sign in book, but I have hit a snag when trying to either update an existing record or create a new one.

I have both arguments in my code but hte are separates by a semi colon and so the app runs both commands, therefore editing one record and creating another.

My code reads

UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"});

If(!IsBlank(Form2),

SubmitForm(Form2)&&

Navigate(ThankYouIn, ScreenTransition.Fade))

 

So it first updates the table if the paramiters are met, but if they are not met I want it to submit form. After each I would want it to navigate to the thank you screen. Both pieces of code work in isolation and both work together but I cannot get them to work Update else work Submit form

 

Any help is much appreciated however daft I have been.

 

Rinceward

 

14 REPLIES 14
Anonymous
Not applicable

Re: I need an Update if Else?

Looks lke you need to simply embed your if statements.  Somthing like...?

 

If(
    //is this true?
    !IsBlank(Form2),
    //if so do these things
    SubmitForm(Form2);
    Navigate(ThankYouIn, ScreenTransition.Fade),
    //else do these things
    UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"});
    Navigate(ThankYouIn, ScreenTransition.Fade)
    )

 

Rinceward
Level: Powered On

Re: I need an Update if Else?

Hi Philashby

 

Thankyou for answering my question so quickly.

 

However this solution does not quite work how I wanted.

 

I have amended the code slightly to check if record is in table firsdt and that updates fine. However if it does not find that record it doesn't create a new record by subitting the table.

 

If( !IsBlank(Form2), UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"}); Navigate(ThankYouIn, ScreenTransition.Fade), SubmitForm(Form2); Navigate(ThankYouIn, ScreenTransition.Fade))

 

So frustrating as it seems so simple Smiley Frustrated

 

Rinceward

Rinceward
Level: Powered On

Re: I need an Update if Else?

Would an or operator work in this situation? Either check if record needs updating OR submit form?

 

Gareth

Anonymous
Not applicable

Re: I need an Update if Else?

Just out of interest, try removing your screen transistion after your form submission.  Maybe the transistion is overriding the submission?  Add in a notify statemrnt to confirm that it's acting that part of the If statement eg Notify( "Should have submitted the form here" )

Rinceward
Level: Powered On

Re: I need an Update if Else?

I have done this and I have gotten the notify to pop up. Again though once the statements are in, It completes both updates the record and then inserts a new record. Both options navigate to correct screen however.

 

If(!IsBlank(Form2),UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"});
SubmitForm(Form2);
Navigate(ThankYouIn, ScreenTransition.Fade))

 

Rince

Anonymous
Not applicable

Re: I need an Update if Else?

Rince,

 

looking at your statement, you don't seem to have an ELSE condition.  It should be seperated by commas.  eg...

 

IF (MYCONDITION, DO THIS, ELSE DO THIS)

 

You can add multiple stages to each area by seperating the commands with semi colons.  

Your code is currently saying...

 

IF (!IsBlank(Form2)...then do these things:

 

First.... UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"});

Then...SubmitForm(Form2);

Then...Navigate(ThankYouIn, ScreenTransition.Fade)

 

But it's not doing any ELSE condition.

 

I think your semicolon (in red) after the Updateif should be a comma?

 

That way it will read

 

IF (!IsBlank(Form2)

 

Do this...UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"}),

 

ELSE do this....

 

SubmitForm(Form2);

Then...Navigate(ThankYouIn, ScreenTransition.Fade)

 

So, try this code..unless I'm misunderstanding the question! - I've added in another transistion after the update.

 

 

If(!IsBlank(Form2),UpdateIf(Table1_14, Name =DataCardValue1.Text && Time_x0020_Out<>Blank() && Time_x0020_In="",{Time_x0020_In:Clock_5.Text, Location: "On Site"});Navigate(ThankYouIn, ScreenTransition.Fade),
SubmitForm(Form2);
Navigate(ThankYouIn, ScreenTransition.Fade))

 

Rinceward
Level: Powered On

Re: I need an Update if Else?

Hi Philashby

 

Thank you for spending so much time helping.

Using your exact code as you said the record will update but it will not create a new record. 

Again it navigates to the correct screen each time

 

Rince

Rinceward
Level: Powered On

Re: I need an Update if Else?

I could also add the creen transition as a separate operation, to take it out of the if else statement.

Would that help?

 

Rince

Anonymous
Not applicable

Re: I need an Update if Else?

Hmmm...it shouldn't matter.

 

I reckon you should go back to basics and test each element - for example, if your button just did a submitForm, does that work?  If it did just the Update, does that work?  Get it to notify the value of each key element, so ensure it's value is what you think it is.  Sometimes, it's something as simple as assuming that a value is X, when in fact it's Y.  Looking at the code, I can't see why it should fail, but without seeing the actual app, it's difficult to tell 😞

 

Good luck!

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,900)