cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Gigaenvy
Level: Powered On

Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

Hi again. So I have this Gallery (popup of an item) that gets it's information from a collection from SP List A. The toggle inside this Gallery however is based on a patch from another SP List B. The toggle functionality works as intended whereby Office365 User comes to the gallery popup and can click 'Signup' (toggle) which then adds the record item to SP List B and then the toggle changes to 'Remove Signup'. Cool!

 

Problem: When the Office365 User comes back to the Gallery item (whether jumping from gallery item to other or refreshing app) the toggle reverts back to the default FalseText Toggle setting of 'Signup'.

 

Ask/Need: I would like the toggle value be remembered/recalled when the user returns to the gallery item. If SP List B column SignedUp has a value of Yes, the TrueText toggle setting should show 'Remove Signup'. He/She can then click the toggle to remove their signup and the SP List B record is deleted. Vice-versa - if user has no data in column SignedUp, then the default 'Sign Up' FalseText of the Toggle value is displayed.

 

Below is my code thus far (thanks @v-xida-msft  for leading the way) which only works until the user comes back. He/she then see's 'Sign Up' again and knows the app is not working properly.

 

SP List B - has column SignedUp (single line of text) that when user clicks 'Sign up' get a Yes value added to the record item for the user.

 

FalseText = "Signup"

TrueText = "Remove Signup"

 

Visible

 

If(ThisItem.Title="Signup",false,true)

 

 

OnChange

 

If(
    Toggle1.Value,
    Patch(                       // Add new record 
           'SP List B', 
            Defaults('SP List B'), 
            {
              Title: "REGISTER",
              FirstName: Office365Users.MyProfile().GivenName,
              LastName: Office365Users.MyProfile().Surname,
              Email: Office365Users.MyProfile().Mail,
              SessionTitle: Title      //Lookup built-in that pulls what it needs to pull from another list
            }
    ),
    RemoveIf(
        'SP List B',
        SessionTitle=ThisItem.Title
    )
)

 

 

The above does what it's supposed to do which is to add the entry (Signup) and delete the record (Remove Signup) from SP List B. The toggle slider works perfectly but only until the User returns to the gallery item or reloads the app and the toggle is back again to the FalseText of 'Signup" toggle slider. 

 

Need/Ask: The toggle needs to be retained but I cannot figure out the visible parameter above and whatever else is needed or suggested.

 

Thanks again and hoping for a reply and your assistance. I am so close but so far in get this right and valuable to the user.

 

Tom

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Level 10

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

Hi @Gigaenvy ,

 

Please set the Default property of Toggle as below:

If(ThisItem.Title in 'SP List B'.SessionTitle, true, false )

If this doesn't make sense, could you share more details with the Title columns?

Best regards,

Sik

View solution in original post

5 REPLIES 5
PowerAddict
Level 10

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

I dont think the answer to your question is the Visible property. What's the default property of your toggle? Seems like your toggle is getting reset everytime the user comes back to the gallery.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com
v-siky-msft
Level 10

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

Hi @Gigaenvy ,

 

Please set the Default property of Toggle as below:

If(ThisItem.Title in 'SP List B'.SessionTitle, true, false )

If this doesn't make sense, could you share more details with the Title columns?

Best regards,

Sik

View solution in original post

Gigaenvy
Level: Powered On

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

HI Kris,

 

This code works and remembers the users toggle when they come back to the app and the gallery item, but what I noticed is that it's adding a new record again to the SP List whenever they come back. Can you help - maybe now this is back to the OnChange code above?

 

Thanks,

 

Tom

v-siky-msft
Level 10

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

Hi @Gigaenvy ,

 

It seems trigger OnChange property again.

I think you can add a new column( SignedUp) in SP list A to save the Signup status.

1. Set the Default property of toggle to If(ThisItme.SignedUp="Yes", True, ThisItem.SignedUp = "No", false )

2. Modify OnChange property,  when switch the toggle, also modify the SignedUp value of SP list A.

 

If(
    Toggle1.Value,
    Patch(                       
           'SP List B', 
            Defaults('SP List B'), 
            {
              Title: "REGISTER",
              FirstName: Office365Users.MyProfile().GivenName,
              LastName: Office365Users.MyProfile().Surname,
              Email: Office365Users.MyProfile().Mail,
              SessionTitle: Title     
            }
    );
    Patch('SP list A', ThisItem,{SignedUp:"Yes"}),
    RemoveIf(
        'SP List B',
        SessionTitle=ThisItem.Title
    );
    Patch('SP list B', ThisItem,{SignedUp:"No"})
)

 

 Best regards,

Sik

Gigaenvy
Level: Powered On

Re: Remember/Collect Toggle value from SP List when Office365 User comes back to Gallery

Hey sorry for not replying. The code suggestions you provided did not work.

 

SP List B is where the user record gets added showing they registered. There's a column inside already called 'Registered' which when they 'Signup' gets an update via the OnChange Patch to "Yes". 

 

Secondarily, there is a column in SP List B called Session Title that gets Patched to the Title of the Session they signed up for when they clicked 'SignUp',

 

There is no SP List A that makes sense here since this list only holds the session information for start date, end, description, title, URL for logo/banner, speaker, seat count, like count etc.

 

I think if to resolve as a solution to the original request we need to focus on SP List B and check if column Registered is already set to "Yes" and ignore any patching. The RemoveIF works perfectly and deletes all entries of the same Session Title.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,084)