Hi,
I have two SP Lists as follows:
What do I want to accomplish?
Whenever the SignUp toggle is pressed, I want to evaluate and patch (SUBTRACT) the Seats Remaining column in SP List A by the difference of Seat Total column. However, please read....The evaluation needs to take into account the total count of existing {'Session Title': Title} from SP List B and then subtract that count total from Seat Total in SP List A, which gives the Seats Remaining value.
If the person returns to this page and the toggle text now say's "Remove SignUp', then we do the inverse of above and ADD the seat back to the Seats Remaining column by the evaluation of counting of Titles.
Can someone help with the code and placement inside below to allow this to work? I have experience with very simple +/- of a single item but not with how the evaluation needs to count first and then perform the calculation.
OnChange Toggle is as follows for: 'SignUp' and 'Remove SignUp'
If(
Toggle1.Value,
Patch( // Add new record
'SP List B',
Defaults('Event Registration'),
{
Title: "REGISTERED",
FirstName: Office365Users.MyProfile().GivenName,
LastName: Office365Users.MyProfile().Surname,
Email: Office365Users.MyProfile().Mail,
'Session Title': Title,
Registered: "Yes"
}
),
RemoveIf(
'SP List B',
'Session Title'=ThisItem.Title
)
)
Thanks,
Tom
Solved! Go to Solution.
Hi @Gigaenvy,
I am confused with the statement "Column 'Session Title is patched to the ThisItem.Title". Where is the toggle? Does it stand in a Gallery? What is the data source of gallery? Could you share more details and screenshots with that?
What's more, what does "take into account the total count of existing {'Session Title': Title} " mean?
From my experience, each time the toggle is turned on, also subtract 1 from the Seats remaining. When the toggle is turned off, just add 1 from the Seats remaining.
If(
Toggle1.Value,
Patch( // Add new record
'SP List B',
Defaults('Event Registration'),
{
Title: "REGISTERED",
FirstName: Office365Users.MyProfile().GivenName,
LastName: Office365Users.MyProfile().Surname,
Email: Office365Users.MyProfile().Mail,
'Session Title': Title,
Registered: "Yes"
};
Patch('SP list A', ThisItem,{'Seats Remaining': ThisItem.'Seats Remaining' +1})
),
RemoveIf(
'SP List B',
'Session Title'=ThisItem.Title
);
Patch('SP list A', ThisItem,{'Seats Remaining': ThisItem.'Seats Remaining' -1})
)
Sik
Hi @Gigaenvy,
I am confused with the statement "Column 'Session Title is patched to the ThisItem.Title". Where is the toggle? Does it stand in a Gallery? What is the data source of gallery? Could you share more details and screenshots with that?
What's more, what does "take into account the total count of existing {'Session Title': Title} " mean?
From my experience, each time the toggle is turned on, also subtract 1 from the Seats remaining. When the toggle is turned off, just add 1 from the Seats remaining.
If(
Toggle1.Value,
Patch( // Add new record
'SP List B',
Defaults('Event Registration'),
{
Title: "REGISTERED",
FirstName: Office365Users.MyProfile().GivenName,
LastName: Office365Users.MyProfile().Surname,
Email: Office365Users.MyProfile().Mail,
'Session Title': Title,
Registered: "Yes"
};
Patch('SP list A', ThisItem,{'Seats Remaining': ThisItem.'Seats Remaining' +1})
),
RemoveIf(
'SP List B',
'Session Title'=ThisItem.Title
);
Patch('SP list A', ThisItem,{'Seats Remaining': ThisItem.'Seats Remaining' -1})
)
Sik
Thanks this worked well and thank you so much for trying to understand what I wrote. You nailed it with the exception of some syntax which was corrected as it wasn't throwing an error on an expression.
User | Count |
---|---|
221 | |
99 | |
94 | |
55 | |
36 |
User | Count |
---|---|
273 | |
104 | |
104 | |
60 | |
60 |