cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anicholls
Helper I
Helper I

UpdateIf Multiple conditions to update collection in gallery view

anicholls_0-1650815905786.png

I am using all of the fields in the gray area as update value fields, the user will type text or select from the drop down what they want the checked records to be overridden with. When you hit apply updates you will see the selected records update only IF there is a value other than blank or empty in the filters shown; otherwise i want the value to remain as is when i hit apply. Right now if I run this only the Audit Name field is updating and it is updating regardless if a selection is made form the drop down or not. Please help:

 

UpdateIf(
colGridData,
ThisRecord in colSelected,
If(
!IsEmpty(SAuditName_1.Selected),
{Audit_x0020_Name: SAuditName_1.Selected},


!IsEmpty(SMgmtBoardMembers_1),
{Mgmt_x0020_Board_x0020_Members: SMgmtBoardMembers_1.Text},


!IsBlank(SMgmtAreaHead_1),
{Mgmt_x0020_Area_x0020_Head: SMgmtAreaHead_1.Text},


!IsBlank(SSrMgmtOwner_1),
{'Sr Mgmt Owner': SSrMgmtOwner_1.Text},


!IsBlank(SProcessOwner_1),
{'Process Owner': SProcessOwner_1.Text},


!IsBlank(SControlOwner_1),
{Control_x0020_Owner: SControlOwner_1.Text},


!IsBlank('SAddtlContact(s)_1'),
{Addt_x0027_l_x0020_Contact_x0028: 'SAddtlContact(s)_1'.Text},


!IsEmpty(SRollUpChainRptg_1.Selected),
{Roll_x0020_Up_x0020_Reporting_x0: SRollUpChainRptg_1.Selected},


!IsEmpty(SReportingChain_1.Selected),
{Reporting_x0020_Chain: SReportingChain_1.Selected},


!IsEmpty(SDepartment_1.Selected),
{Department: SDepartment_1.Selected},


!IsEmpty('SSub-department_1'.Selected),
{'Sub-Department': 'SSub-department_1'.Selected},


!IsEmpty(SProcess_1.Selected),
{Process: SProcess_1.Selected},


!IsEmpty(SAuditID_1.Selected),
{'Audit Id': SAuditID_1.Selected}
)
);
Clear(colSelected);
Reset(checkboxall);
Reset(SAuditName_1);
Reset(SControlOwner_1)

1 ACCEPTED SOLUTION

Accepted Solutions
v-liwei-msft
Microsoft
Microsoft

 
Could you please tell me if you use the if function first judge"! Isempty (sauditname_1. Selected)" and get the result of" {audit_x0020_name: sauditname_1. Selected} "when this condition is true. After that, your if function cannot traverse the subsequent conditions and results?
There can be multiple conditions in the if function, but after it meets the first condition, it will only return the result of the first condition, and the remaining conditions and results will not continue to appear. So you can use the patch function to merge multiple records into one record, and nest multiple if functions in the patch function.
I will give you my solution for your reference:
UpdateIf(
colGridData,
ThisRecord in colSelected,
Patch(
If(
!IsEmpty(SAuditName_1.Selected),
{Audit_x0020_Name: SAuditName_1.Selected}
),
If(
!IsEmpty(SMgmtBoardMembers_1),
{Mgmt_x0020_Board_x0020_Members: SMgmtBoardMembers_1.Text}
),
If(
!IsBlank(SMgmtAreaHead_1),
{Mgmt_x0020_Area_x0020_Head: SMgmtAreaHead_1.Text}
)
If(
!IsBlank(SSrMgmtOwner_1),
{'Sr Mgmt Owner': SSrMgmtOwner_1.Text}
)
If(
!IsBlank(SProcessOwner_1),
{'Process Owner': SProcessOwner_1.Text}
)
If(
!IsBlank(SControlOwner_1),
{Control_x0020_Owner: SControlOwner_1.Text}
)
If(
!IsBlank('SAddtlContact(s)_1'),
{Addt_x0027_l_x0020_Contact_x0028: 'SAddtlContact(s)_1'.Text}
)
If(
!IsEmpty(SRollUpChainRptg_1.Selected),
{Roll_x0020_Up_x0020_Reporting_x0: SRollUpChainRptg_1.Selected}
)
If(
!IsEmpty(SReportingChain_1.Selected),
{Reporting_x0020_Chain: SReportingChain_1.Selected}
)
If(
!IsEmpty(SDepartment_1.Selected),
{Department: SDepartment_1.Selected}
)
If(
!IsEmpty('SSub-department_1'.Selected),
{'Sub-Department': 'SSub-department_1'.Selected}
)
If(
!IsEmpty(SProcess_1.Selected),
{Process: SProcess_1.Selected}
)
If(
!IsEmpty(SAuditID_1.Selected),
{'Audit Id': SAuditID_1.Selected}
)
)
)

I think this link will help you a lot :Patch function in Power Apps (contains video) - Power Apps | Microsoft Docs

 
Beat Regards,

Levi

 

View solution in original post

3 REPLIES 3
anicholls
Helper I
Helper I

Another attempt at what I am trying to do, if the dropdown uptop does not have a value then don't update the value in the gallery leave as is. This isn't working either it is just updating the value to blank:

 

anicholls_0-1650822024394.png

 

v-liwei-msft
Microsoft
Microsoft

 
Could you please tell me if you use the if function first judge"! Isempty (sauditname_1. Selected)" and get the result of" {audit_x0020_name: sauditname_1. Selected} "when this condition is true. After that, your if function cannot traverse the subsequent conditions and results?
There can be multiple conditions in the if function, but after it meets the first condition, it will only return the result of the first condition, and the remaining conditions and results will not continue to appear. So you can use the patch function to merge multiple records into one record, and nest multiple if functions in the patch function.
I will give you my solution for your reference:
UpdateIf(
colGridData,
ThisRecord in colSelected,
Patch(
If(
!IsEmpty(SAuditName_1.Selected),
{Audit_x0020_Name: SAuditName_1.Selected}
),
If(
!IsEmpty(SMgmtBoardMembers_1),
{Mgmt_x0020_Board_x0020_Members: SMgmtBoardMembers_1.Text}
),
If(
!IsBlank(SMgmtAreaHead_1),
{Mgmt_x0020_Area_x0020_Head: SMgmtAreaHead_1.Text}
)
If(
!IsBlank(SSrMgmtOwner_1),
{'Sr Mgmt Owner': SSrMgmtOwner_1.Text}
)
If(
!IsBlank(SProcessOwner_1),
{'Process Owner': SProcessOwner_1.Text}
)
If(
!IsBlank(SControlOwner_1),
{Control_x0020_Owner: SControlOwner_1.Text}
)
If(
!IsBlank('SAddtlContact(s)_1'),
{Addt_x0027_l_x0020_Contact_x0028: 'SAddtlContact(s)_1'.Text}
)
If(
!IsEmpty(SRollUpChainRptg_1.Selected),
{Roll_x0020_Up_x0020_Reporting_x0: SRollUpChainRptg_1.Selected}
)
If(
!IsEmpty(SReportingChain_1.Selected),
{Reporting_x0020_Chain: SReportingChain_1.Selected}
)
If(
!IsEmpty(SDepartment_1.Selected),
{Department: SDepartment_1.Selected}
)
If(
!IsEmpty('SSub-department_1'.Selected),
{'Sub-Department': 'SSub-department_1'.Selected}
)
If(
!IsEmpty(SProcess_1.Selected),
{Process: SProcess_1.Selected}
)
If(
!IsEmpty(SAuditID_1.Selected),
{'Audit Id': SAuditID_1.Selected}
)
)
)

I think this link will help you a lot :Patch function in Power Apps (contains video) - Power Apps | Microsoft Docs

 
Beat Regards,

Levi

 
v-liwei-msft
Microsoft
Microsoft

Hi @anicholls   ,
Could you please tell me if my reply help you solve this problem? I would be grateful if you can reply to me at your earliest convenience.
 
Beat Regards,

Levi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,909)