Hi Community, can I improve the below code to bring it into one IF statement instead of 2? The 3rd patch should be done at the same time as the second if the condition is met
If(
MentorGallery.Selected.'Current Registrations' >= 5,
Patch(
UAWaitingList,
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
),
Patch(
UARegistrationList,
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
)
);
If(
MentorGallery.Selected.'Current Registrations' >= 5,
Patch(
UAMentorList,
First(
Filter(
UAMentorList,
ID = MentorGallery.Selected.ID
)
),
{CurrentRegistrations: MentorGallery.Selected.'Current Registrations' + 1}
)
)
Thanks
Hi @MarkH1 ,
Could you please share a bit more about your scenario?
Do you want to merge the two If condition into single one?
I have made a test on my side, please modify your formula as below:
If(
MentorGallery.Selected.'Current Registrations' >= 5,
Concurrent(
Patch(
UAWaitingList,
Defaults(UAWaitingList),
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
),
Patch(
UAMentorList,
LookUp(UAMentorList,ID = MentorGallery.Selected.ID),
{
CurrentRegistrations: MentorGallery.Selected.'Current Registrations' + 1
}
)
),
Patch(
UARegistrationList,
Defaults(UARegistrationList)
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
)
)
Note: The Concurrent function could execute multiple formulas simultaneously, which would improve your app's performance.
Best regards,
Hi @MarkH1 ,
All you need to do is add that patch right next to the first path. I am 100% sure you know the syntax for if in Power Appss is:
if(<<condition>>,true,false)
If(5 > 3,
UpdateContext({varValue1: "Value1"});
UpdateContext({varValue2: "Value2"});
,
UpdateContext({varValue3: "Value3"});
)
if see in the above code block I am executing 2 statement if the condition is met. having said that how we can achieve your need is as below.
If(
MentorGallery.Selected.'Current Registrations' >= 5,
Patch(
UAWaitingList,
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
);
Patch(
UAMentorList,
First(
Filter(
UAMentorList,
ID = MentorGallery.Selected.ID
)
),
{CurrentRegistrations: MentorGallery.Selected.'Current Registrations' + 1}
);,
Patch(
UARegistrationList,
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
)
);
Hope this helps.
Regards,
Krishna
If this reply/solution helps Mark it as the solution and give a thumbs-up.
Hi @MarkH1
Would this work?
Switch(
MentorGallery.Selected.'Current Registrations' >= 5,
Patch(
UAWaitingList,
Defaults(
'Current Registrations'
),
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
),
Patch(
UARegistrationList,
Defaults(
UARegistrationList
),
{
Title: User().FullName,
MenteeMail: User().Email,
Mentor: MentorGallery.Selected.Title
}
),
Patch(
UAMentorList,
Lookup(
UAMentorList,
ID = MentorGallery.Selected.ID
),
{
CurrentRegistrations: MentorGallery.Selected.'Current Registrations' + 1
}
)
)
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2