cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IntraAdmin
Helper I
Helper I

Nested If statement not recognizing true

I have the following nested IF statement:

 

If(varHR=true||varIntranetAdmin=true,If(varENF=true||varBSD=true||varTRN=true,DisplayMode.View),DisplayMode.Edit)

The variable varENF = true according to the label I created for testing but it returns DisplayMode.Edit.  I want some fields to be read-only depending upon login group.  Any help is much appreciated. 

2 ACCEPTED SOLUTIONS

Accepted Solutions

try this:

if((varIntranetAdmin || varHR) && (varContractHM && IsBlank(EmployeeType)), DisplayMode.Edit,DisplayMode.View)

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

 

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


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, Microsoft Certified Trainer
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.

View solution in original post

@KrishnaV  Again, thank you.  For anyone coming to this for a solution, for me I needed to replace the && with || (in red font below)between first two conditions and the second:

 

If((varHR||varIntranetAdmin)||(varContractHM && IsBlank(EmployeeType)),DisplayMode.Edit,DisplayMode.View)

View solution in original post

11 REPLIES 11
Jeff_Thorpe
Super User
Super User

What are the values of varHR and varIntranetAdmin?



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
KrishnaV
Super User III
Super User III

Hi @IntraAdmin ,

 

The if the syntax is wrong because a boolean variable need not to be validated as varHR=true, try the below see the result as needed:

 

 

If(varHR||varIntranetAdmin,
     If(varENF||varBSD||varTRN,DisplayMode.View)
   ,DisplayMode.Edit)

 

 

As per the logic you written, how it works is: if varHR or VarIntranetAdmin is true then it will further validate for varEnf or varBSD or VarTRN to be true to show the label in view mode if not it will show as edit mode. 

 

By the way, I am assuming that you are writing this formula at DisplayMode property of the input text control.

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

 

Regards,

Krishna
If this post helps, then please consider Accept it as the solution and give thumbs-up to help the other members find it more.

 


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, Microsoft Certified Trainer
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.

@Jeff_Thorpe   My value for varENF is true

                           varIntranetAdmin is false

                           varHR is false

 

@KrishnaV  Thank you for your help.  That formula did not work.  I have it in the DisplayMode property but also tried it in Default.  

 

Both formulas are allowing edits.   When I set a label to MyDataCardValue.DisplayMode it is returning blank (not with Edit or View).

UPDATE:  The DisplayMode is showing Edit no matter who is logged in.

The formula is written, so that if varIntranetAdmin is false and varHR is false then DisplayMode.Edit

DisplayMode.View will only happen if (varIntranetAdmin or varHR is true) and (varEN or varBSD or varTRN are true).



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Hi @IntraAdmin ,

 

I see these are the below variables in the formula, if you could tell me the business logic like when you want the field to edit mode and when you want it to display mode:

varHR,varIntranetAdmin,varENF, varBSD, varTRN

 

Let me know I am always happy to help.

 

Regards,

Krishna


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, Microsoft Certified Trainer
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.

@KrishnaV @Jeff_Thorpe    

 

If logged in User() is in AAD group then set varX to true.   

 

So if varIntranetAdmin is true then every other variable will be false.  If this is the case, then set DisplayMode.Edit.

If varHR is true then every other variable will be false.  If this is the case, then set DisplayMode.Edit,

ELSE If varENF is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

If varTRN is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

If varENF is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

If varITD is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

If varBSD is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

If varHirMgr is true, then every other variable will be false. If this is the case, then set DisplayMode.View, 

 

Also, If varContractHM is true and EmployeeType is blank, then every other variable will be false. If this is the case, then set DisplayMode.Edit, 

 

My logic on getting logins and setting tabs is working.  I am not sure why I am getting so hung up on this.

 

Thank you both for your help!

 

try this:

if((varIntranetAdmin || varHR) && (varContractHM && IsBlank(EmployeeType)), DisplayMode.Edit,DisplayMode.View)

 

I hope this resolved your issue if you see any challenge let me know I am always happy to help.

 

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


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, Microsoft Certified Trainer
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.

View solution in original post

@KrishnaV  Thank you so much!! That works and makes sense.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,913)