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 / Update Dropdown select...
Power Apps
Answered

Update Dropdown selection based on current dropdown selection and toggle switch value

(0) ShareShare
ReportReport
Posted on by 25

I have a SharePoint list with a Choice column (Status where values are "New Request", "Active', "On Hold", "Closed") and a Toggle Switch (Approved where values are true or false).

On the EditForm, when a user changes the Toggle Switch to true, I want the Status dropdown column selection to change to "Active" but only when its value is "New Request".  If the user changes the Approved toggle switch to false, I do not want the Status dropdown column selection to change.

I've been searching the forums and trying different solutions with no luck.

The closest I've gotten to a resolution is the following:

-- save the value of the Status dropdown selected value when loading form:

SharePointIntegration OnEdit:   EditForm(SharePointForm1);Set(varOrigStatus, StatusDataCardValue.Selected.Value);

-- save the value of the Status dropdown selected value when the Approved toggle switch is changed:

ApprovedDataCardValue OnChange:  Set(varOrigStatus, StatusDataCardValue.Selected.Value)

-- save the value of the Status dropdown selected value when a user selects a different value:

StatusDataCardValue OnSelect: Set(varOrigStatus, StatusDataCardValue.Selected.Value)

-- automatically change the Status dropdown selection to "Active" if dropdown selection is "New Request" and Approved toggle switch is true, else keep as Status dropdown selection as is:

StatusDataCard Default:  If(varOrigStatus="New Request" And ApprovedDataCardValue.Value, LookUp(Choices('Test List'.Status), Value = "Active"), LookUp(Choices('Test List'.Status), Value = varOrigStatus))

 

I believe my biggest problem is trying to check the current value of the Status dropdown value before changing it to "Active".  If I check the dropdown directly, I get a circular reference.

Any help would be appreciated!

 

Categories:
  • R3dKap Profile Picture
    1,594 on at

    Hi @gol2,

    Here is how I would do it (tested on my side):

     

    SharePointIntegration.OnEdit = EditForm(SharePointForm1); Reset(ApprovedDataCardValue); Set(varForcedStatus, Blank())
    
    ApprovedDataCardValue.OnCheck = Set(varForcedStatus, {Value: "Active"})
    
    StatusDataCard.DefaultSelectedItems = If(SharePointForm1.Mode = FormMode.Edit && SharePointIntegration.Selected.Status.Value = "New Request" && Not(IsBlank(varForcedStatus)), {Value: "Active"}; Parent.Default)

     

    Tell us if this works for you as expected...

  • gol2 Profile Picture
    25 on at

    @R3dKap , Thank you for your reply.

    A couple questions on proposed solution (which isn't working for me, but I'll try again):

    1. Should this be for StatusDataCardValue instead of StatusDataCard?  (there is no DefaultSelectedItems property on StatusDataCard) 

    StatusDataCard.DefaultSelectedItems = If(SharePointForm1.Mode = FormMode.Edit && SharePointIntegration.Selected.Status.Value = "New Request" && Not(IsBlank(varForcedStatus)), {Value: "Active"}; Parent.Default)

     2. Should the semi-colon prior to Parent.Default in above formula be a comma instead?  The above formula gave me an error.  Changing it to a comma cleared the error.

  • R3dKap Profile Picture
    1,594 on at

    Yes sorry you are right about the two mistakes... So is it working as expected now?

  • gol2 Profile Picture
    25 on at

    No.  It is not.  

  • R3dKap Profile Picture
    1,594 on at

    Can you post a capture of the error showing the error message please?

  • gol2 Profile Picture
    25 on at

    No error.  I tried again.  It works the first time a user switches Approved to true, but if a user decides to flip the Approved switch and change status, prior to saving it no longer works.  So, you've provided a partial solution and I thank you for that.  

    SPExample.PNG

  • R3dKap Profile Picture
    1,594 on at

    OK. In that case just add this code before the Set() function in Approved_DataCard.OnCheck:

     

    Reset(StatusDataCardValue)

  • gol2 Profile Picture
    25 on at

    @R3dKap ,

    The last code provided fixes the last Use Case I presented, but unfortunately, doesn't work for this Use Case

    (assumed the change should be to ApprovedDataCardValue.OnCheck since there is no Approved_DataCard OnCheck event) :

     

    SPExample2.PNG
  • Verified answer
    R3dKap Profile Picture
    1,594 on at

    Hi @gol2,

    Ok... I've simplified the technique and it works on my side for all your use cases:

    SharePointIntegration.OnEdit = EditForm(SharePointForm1);; Set(varStatus; SharePointIntegration.Selected.Status)
    
    StatusDataCardValue.OnChange = Set(varStatus; Self.Selected)
    StatusDataCardValue.DefaultSelectedItems = varStatus
    
    ApprovedDataCardValue.OnCheck = If(varStatus.Value = "New Request"; Set(varStatus; {Value: "Active"});; Reset(StatusDataCardValue))

     

    That should do it... 😉

  • gol2 Profile Picture
    25 on at

    @R3dKap ,

    Thank you!  I appreciate the time you spent helping me solve my issue.

    I made a few tweaks to the last solution you provided and it works!  (There seems to be an issue with commas being replaced with semi-colons when your last solution was posted.)

    Here is the technique I ended up using ((Note, we are on PowerApps version 3.22022.31 so we don't have the most recent updates):

    SharePointIntegration.OnEdit:

    ResetForm(SharePointForm1);EditForm(SharePointForm1);Set(varStatus, SharePointIntegration.Selected.Status)

     

    StatusDataCardValue.OnChange:

    Set(varStatus, Self.Selected)

    StatusDataCardValue.DefaultSelectedItems:

    Parent.Default 

     

    Status_DataCard.Default:

    If (SharePointForm1.Mode = FormMode.Edit And Not(IsBlank(varStatus)), varStatus, ThisItem.Status)

     

    ApprovedDataCardValue.OnCheck:

    If(varStatus.Value = "New Request", Set(varStatus, {Value: "Active"}))

    (removed the Reset(StatusDataCardValue) )

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard