cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IzzyWizz
Helper III
Helper III

Patch to update a record in a Sharepoint list

Hi,

I have a SharePoint list that I use to collect data from onsite audits. I have a gallery that displays the completed audit information where you can click though to display the details from a selected gallery item:

AuditGallery.jpg

The Action Required box on the second screen is populated from the background SharePoint list for the selected item:

AuditGalleryPage2.jpg

I have a Patch function on the update button that I want to update the Audit Type and Action Required (you can't change the image at the moment, that will be phase2!). The code is below:

Set(
    varPatchAudit2,
    Patch(
        'Hygiene Fabrication Audits',
        Defaults('Hygiene Fabrication Audits'),
        {
           
            AuditType: Dropdown1_1.Selected.Value,
            Title: Dropdown1_1.Selected.Value,
            ActionRequired: ActionRequiredInput_1.Text,
            TaskStatus: "Not started",
            AssignedBy: If(
                Dropdown1_1.Selected.Value = "Fabrication",
                FabManager,
                HygManager
            ),
            AssignedTo: "Unassigned"
            
        }
    )
);

My problem is that it is that the update is not registering anything new, i.e. if I change the Audit Type via the dropdown or the text in the Action Required, the background list is not changing. Either the Patch is not working or it is putting back the same information without picking up the changes.

Any ideas what I am doing wrong?

Thanks,

Izzy.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @IzzyWizz ,

If you want to update the existing record on change then Instead of Default you can use like below.
You need to Pass the ID of that record that you want to Update. 
For reference - See below Image

VijayTailor_0-1601892583195.png

 

Thanks,

Vijay

View solution in original post

3 REPLIES 3
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @IzzyWizz ,

As I can see in the below-mentioned Code is like you are patching the Choices Field but you Passing value like a text.
SO If your Source having FIeld "AuditType" is Choice Field then you can Patch Value Like Below.

AuditType:{
            Value:"Submitted",
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
        }

The same thing is Applicable to Person Field also.
Like for the Field -  Field (If your Source Having "AssignedBy" field as a Person or Group Type)

//AssignedBy
AssignedBy: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims: "i:0#.f|membership|"&Lower(User().Email),
                DisplayName: User().FullName,
                Email: Lower(User().Email),
                Picture: User().Image,
                Department: "",
                JobTitle: ""

              }


Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."



Hi,

No, Audit Type is a text field, I just use a dropdown to limit the options for the text that people can input. I want the text that I have already patched to the Audit Type and Action Required fields to be updated with the new information, replacing what has successfully patched there previously.

Izzy.

Hi @IzzyWizz ,

If you want to update the existing record on change then Instead of Default you can use like below.
You need to Pass the ID of that record that you want to Update. 
For reference - See below Image

VijayTailor_0-1601892583195.png

 

Thanks,

Vijay

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,254)