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 / Best practice when Pat...
Power Apps
Unanswered

Best practice when Patching/UpdateIf to a SharePoint List with multiple ComboBoxs?

(0) ShareShare
ReportReport
Posted on by 829

HI Folks -

 

I have both Patch & UpdateIf functionality that is triggered OnSuccess that Patches/Updates another SharePoint List.  Right now, I only have two fields included as the values I'm patching/updating will always be the same therefore the IDs of the values in the Target field are the same.  With that said, I want to include other fields but all of my other fields I want to include are ComboBoxs with a handful of choices each.

 

How does everyone manage this? Do I need to set up additional if or switch statements within the Patch/UpdateIf functionality to first check the value, and then use the appropriate ID from the target field?

 

Here is one of my current UpdateIf's:

		UpdateIf(
			rdInvestments,
				Mid(ProjectCode,5,5)=Mid(AssetEditForm.LastSubmit.Name,5,5),
				{
					PartnershipID:Blank(),
					PartnershipAlias:Blank(),
					Partnered:
						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
						Id:1, Value:"No"},
					RequestStatus:
					{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
						Id:6, Value:"On-Hold"}
				}
		)

Would I need to add  If or Switch logic to the ID and Value portions?

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @simms7400 

    UpdateIf has a better experience than the Patch statement for multiple reasons. But I will take you formula with the UpdateIf as the example.

    One thing of note is that your criteria for the record match is NOT going to be delegable, so if you expect to have more than 2000 records in your datasource, this will be a concern.  If not, then it is merely a performance concern.

     

    I am not understanding this statement you made : "Right now, I only have two fields included as the values I'm patching/updating will always be the same therefore the IDs of the values in the Target field are the same. "

     

    Now, breaking down the formula:

    UpdateIf(
     rdInvestments,
    
     // NOTE 1
     Mid(ProjectCode,5,5)=Mid(AssetEditForm.LastSubmit.Name,5,5),
     {
     // NOTE 2
     PartnershipID:Blank(),
     PartnershipAlias:Blank(),
    
     // NOTE 3
     Partnered:
     {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id:1, Value:"No"},
     RequestStatus:
     {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id:6, Value:"On-Hold"}
     }
    )

    NOTE 1: Again...this is not delegable.

    NOTE 2: I am not sure what these are or mean to you and why you are trying to set them to blank()

    NOTE 3: You mentioned comboboxes, but these seem hard-coded into the formula.  And also, if they are Choice columns in your datasource, then you do not need to supply and Id...as there is not Id on a choice column.  Only on Lookup columns.  Also, the @odata.type part is no longer needed in the formula.

     

    So, other than the statement I did not understand above, if you could also expand on the formula comments, perhaps we can figure out what is best for you.

    I hope this is helpful for you.

  • simms7400 Profile Picture
    829 on at

    Hi @RandyHayes 

     

    Sorry for the confusion! I only posted my current logic and didn't also include an example of what I had in mind.  Here it is:

    		UpdateIf(
    			rdAssets,
    				Concatenate("PFR-",ResearchCode)=TargetEditForm.LastSubmit.TargetID,
    				{
    					Target_x0020_Short_x0020_Name:TargetEditForm.LastSubmit.Target_Short_Name,
    					Target_x0020_Long_x0020_Name:TargetEditForm.LastSubmit.Target_Long_Name,
    					PRD_DDU:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Id:Switch(
    							TargetEditForm.LastSubmit.Modality_Detail,"val1",1,
    							TargetEditForm.LastSubmit.Modality_Detail,"val2",2					
    						),
    						Value:TargetEditForm.LastSubmit.Mechanism},
    					Modality_Detail:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Id:Switch(
    							TargetEditForm.LastSubmit.Modality_Detail,"val1",1,
    							TargetEditForm.LastSubmit.Modality_Detail,"val2",2,
    						),
    						Value:TargetEditForm.LastSubmit.Modality_Detail},
    					DDU_Portfolio:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Id:Switch(
    							TargetEditForm.LastSubmit.DDU_Portfolio,"va1",1,
    							TargetEditForm.LastSubmit.DDU_Portfolio,"val2",2				
    						), 
    						Value:TargetEditForm.LastSubmit.DDU_Portfolio},
    					RequestStatus:
    					{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Id:6, Value:"Updated"}
    				}
    		)

     

    But based on your last point, you're saying I don't need to supply the ID if my data source is a Choice field? Interesting!! This could make things easier.  My source for these "Choice" fields is SharePoint, but not lookup columns.

     

    So in theory, this should be what I implement?

     

    		UpdateIf(
    			rdAssets,
    				Concatenate("PFR-",ResearchCode)=TargetEditForm.LastSubmit.TargetID,
    				{
    					Target_x0020_Short_x0020_Name:TargetEditForm.LastSubmit.Target_Short_Name,
    					Target_x0020_Long_x0020_Name:TargetEditForm.LastSubmit.Target_Long_Name,
    					PRD_DDU:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Value:TargetEditForm.LastSubmit.Mechanism},
    					Modality_Detail:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Value:TargetEditForm.LastSubmit.Modality_Detail},
    					DDU_Portfolio:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Value:TargetEditForm.LastSubmit.DDU_Portfolio},
    					RequestStatus:
    						{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    						Value:"Updated"}
    				}
    		)

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard