web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I combine two c...
Power Apps
Answered

How do I combine two conditions for the DefaultSelectedItems property of a combobox?

(0) ShareShare
ReportReport
Posted on by 634

Future_Vision_1-1620151134710.png

 

I'll try and explain this the best that I can. These 3 fields all work together. The Third Party field is hidden unless you choose a value that contains "3rd" in it.

If("3rd" in Source_CB.Selected.crfeb_source,true,false)

The Add Third Party field(group) is hidden if the add3rdPtyGRP variable is false. The Add Third Party button OnSelect sets this variable to true which reveals the group. It also sets add3rdPtyBTN to false which sets its Visible property to false

 

When you type a value into the Add Third Party field and click Add a variable called newThird is set to the value of the Add Third Party field. This value is then patched to the datasource of the Third Party field and the field is refreshed like this
Note: add3rdPtyGRP and add3rdPtyBTN are also changed although this is not important

 

If(
 !IsBlank(AddThirdParty_TB.Value),
 UpdateContext(
 {
 newThird: Patch(
 'Third Parties',
 {'Third Party (crfeb_thirdparty)': AddThirdParty_TB.Value}
 )
 }
 );
 Reset(AddThirdParty_TB)
);
Set(
 add3rdPtyGRP,
 false
);
Set(
 add3rdPtyBTN,
 true
)

 

All fine and dandy. The DefaultSelectedItems property for Third Party is set to newThird if a value exists otherwise it defaults to the parent like this.

 

If(IsBlank(newThird),{crfeb_thirdparty:Parent.Default},newThird)

 

Again, all is great, however if I am editing or making a copy of the original record and change the value in the Source field to a value that does not contain "3rd" in the value the default value of the parent still exists behind the scenes in a global variable called glbFormData. What I basically need to be able to do, in the case of an edit/copy where the Source changes to a value that does not contain "3rd"  is make that Third Party field blank in glbFormData so that when I submit it that value is no longer available. I'm not sure exactly how to do this though. I need to be able to account for the existence of a value in the newThird variable and use that value in the Third Party field when the conditions match otherwise I need to use the value in glbFormData for Third Party unless the Source  field does not contain "3rd" in the value in which case I then need to set the glbFormData.'Third Party'  to blank.

 

Hopefully that is clear. It's barely clear to me and my non-programmer mind. Lol!

 

Categories:
I have the same question (0)
  • Wayne_A Profile Picture
    113 on at

    Are you not able to just use an And() function within your If()?
    e.g.
    If(And(IsBlank(newThird),SomeOtherScenarioHere),{crfeb_thirdparty:Parent.Default},newThird)
    or would an Or() function work better for your scenario and maybe not an And()?


    Like it? please click the Thumbs Up button!
    Problem Solved? please click the Accept as Solution button to help other Community members find the answer as well!

  • Future_Vision Profile Picture
    634 on at

    Hmm. I've been playing with that but I don't think that works. I think I may need nested if statements. In one case the field should be set to the variable newThird and in another case it should be set to Blank(). I think a potential solution is to remove the value from the record when the field is inactivated if that makes sense. 

     

    If the user ads a new third party then the field is set to the value of the newThird variable. If the user sets the source to a value that does not include "3rd" then the glbFormData.thirdparty is set to blank. 

  • Verified answer
    Future_Vision Profile Picture
    634 on at

    Turn out the simplest way I could find to solve this was set that Third Party field to disabled if "3rd" was in the selected value of the Source field like this:

     

    If("3rd" in Source_CB.Selected.crfeb_source,DisplayMode.Edit,DisplayMode.Disabled)

     

     

    Appears to have solved the problem

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 490

#2
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 381

Last 30 days Overall leaderboard