cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

If condition is not working as expected!

Hello,

 

My objective is as follows:

 

If EditForm mode == Edit, then do nothing

If EditForm mode == New, then create a record

 

Therefore, I have written following formula:

If(EditForm.Mode=FormMode.Edit,"",Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})); --> It's not working

If(EditForm.Mode=FormMode.New,Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})); -->It's not working

 

Can you please share where I am wrong here?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

While checking on this further, I see that If condition is not working because:

 

FormMode is returning "0" value if FormMode == New and Edit, there is no differentiation between New and Edit, therefore if condition is not working out.

 

Therefore, now I have declared variable called EditFormMode, if NewForm mode is navigated, then EditFormMode = 1, If Edit form mode is navigated then EditFormMode = 0

 

and using the following formula, which is working as expected:

 

If((EditFormMode = 1),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'}))

 

Thank you!

 

View solution in original post

4 REPLIES 4
Super User II
Super User II

Hi @dave8 ,

 

Try this:

If(!(yourformanem.Mode = FormMode.Edit),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'}))

If((yourformanem.Mode = FormMode.Edit),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'}));

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Hi @KrishnaV 

 

Both are not working as it should:

 

If(!(yourformanem.Mode = FormMode.Edit),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})) - This doesn't patch, if FormMode is New

If((yourformanem.Mode = FormMode.Edit),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})); - This does patch regardless if FormMode is Edit


While my requirement is, It should only patch if FormMode = New

 

I then try with following formulas:

If(!(yourformanem.Mode = FormMode.New),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})) - This does patch regardless if FormMode is New

 

If((yourformanem.Mode = FormMode.New),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'})) - This does note patch if FormMode is New

 

How do I patch ONLY if form mode == New?
 
Thanks,

While checking on this further, I see that If condition is not working because:

 

FormMode is returning "0" value if FormMode == New and Edit, there is no differentiation between New and Edit, therefore if condition is not working out.

 

Therefore, now I have declared variable called EditFormMode, if NewForm mode is navigated, then EditFormMode = 1, If Edit form mode is navigated then EditFormMode = 0

 

and using the following formula, which is working as expected:

 

If((EditFormMode = 1),Patch('Updates',Defaults('Updates'),{'Status':'In Progress'}))

 

Thank you!

 

View solution in original post

Since that the issue is resolved please mark the relevant reply as a solution so that it will help the new members in the community. 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,830)