cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dave8
Impactful Individual
Impactful Individual

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
dave8
Impactful Individual
Impactful Individual

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
KrishnaV
Super User III
Super User III

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.

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.
dave8
Impactful Individual
Impactful Individual

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,

dave8
Impactful Individual
Impactful Individual

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.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (27,582)