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 / Patch function in a Sh...
Power Apps
Unanswered

Patch function in a Sharepoint form - New and editted items?

(0) ShareShare
ReportReport
Posted on by 878

Hey! I finally managed to set up the Patch function to a button in my form.

Problem is, I didn't know that this would mean that even if I'm editing items, it will still create a new item. 

I need a way for the program to know when it is a new form and and edited form.

Through ChatGPT i found this formula but can get it to work:

Set(varRecord; LookUp(SharePointList; ID = SharepointForm1.LastSubmit.ID));
If(
!IsBlank(varRecord);
Patch(
SharepointList;
varRecord;
{
PATCHED ELEMENTS
}
);
Patch(
SharepointList;
Defaults(SharepointList);
{
PATCHED ELEMENTS
}
)
)

Do you have other suggestions or ways this code could work?

Categories:
  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @WorkingRicardo ,

     

    Since you are editing a SharePoint form, there's an object in there called SharePointIntegration. This object can be referenced to get data on, for instance, the selected record. For your formula this means you should be referencing this object instead of SharePointForm1.LastSubmit:

     

    Set(varRecord; LookUp(SharePointList; ID = SharePointIntegration.Selected.ID));
    If(
    !IsBlank(varRecord);
    Patch(
    SharepointList;
    varRecord;
    {
    PATCHED ELEMENTS
    }
    );
    Patch(
    SharepointList;
    Defaults(SharepointList);
    {
    PATCHED ELEMENTS
    }
    )
    )

     

    More info can be found here: https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/sharepoint-form-integration

  • WorkingRicardo Profile Picture
    878 on at

    Hey @BCBuizer ty for the reply!

    I tried it as you said, but even at the begining of the formula is making errors, as the IF or ISBLANK are not showing in light blue colors... That normally means that there is an error, no?

    I typed this:

    Set(varRecord; LookUp(Incidencias; ID = SharePointIntegration.Selected.ID));
    If(
    !IsBlank(varRecord);

    What could be going wrong?

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @WorkingRicardo ,

     

    I'm not sure what you mean with light blue colours, so can you please share a screenshot?

     

    If you have any errors, they should show up in the app checker: 

    BCBuizer_0-1701785778859.png

     

    Please share the errors you receive.

  • swaminawale Profile Picture
    195 on at

    Hi @WorkingRicardo ,

     

    You used 'Semicolons' you need to use comma in the formula

     

    Set(varRecord, LookUp(Incidencias, ID = SharePointIntegration.Selected.ID));
  • swaminawale Profile Picture
    195 on at

    Are you using Gallery to display all records and there do you have edit icon to edit the records?

  • WorkingRicardo Profile Picture
    878 on at

    @swaminawale @BCBuizer Hey thanks for your replies. This is my full code at the moment: 

    Set(VariableRecord; LookUp(Incidencias; ID = SharePointIntegration.Selected.ID));
    If(
     !IsBlank(VariableRecord);
    Patch(
     Incidencias;
     VariableRecord;
     { 
     Cliente:{Value:DataCardValue14.Selected.Cliente};
     Incidencia:{Value:DataCardValue1.Selected.Value};
     Producto:{Value:DataCardValue12.Selected.Producto};
     'Departamento encargado':{Value:DataCardValue3.Selected.Value};
     'Número Documento':DataCardValue13.Text;
     'Personal encargado':DataCardValue4.SelectedItems;
     Estado:{Value:DataCardValue2.Selected.Value};
     'Propuesta resolución':DataCardValue10.SelectedDate;
     'Fecha de resolución':DataCardValue7.SelectedDate;
     'Registro incidencia':DataCardValue5.SelectedDate
     }
    );
    Patch(
     Incidencias;
     Defaults(Incidencias);
     { 
     Cliente:{Value:DataCardValue14.Selected.Cliente};
     Incidencia:{Value:DataCardValue1.Selected.Value};
     Producto:{Value:DataCardValue12.Selected.Producto};
     'Departamento encargado':{Value:DataCardValue3.Selected.Value};
     'Número Documento':DataCardValue13.Text;
     'Personal encargado':DataCardValue4.SelectedItems;
     Estado:{Value:DataCardValue2.Selected.Value};
     'Propuesta resolución':DataCardValue10.SelectedDate;
     'Fecha de resolución':DataCardValue7.SelectedDate;
     'Registro incidencia':DataCardValue5.SelectedDate
     }
    )
    );;
    RequestHide()

    The RequestHide() was added as I need that when you push this button it saves and exits the form. Altough for new entries this makes it so all patched items are still marked. If you know a way I can make it so the form disappear and refreshes for new entries, let me know.

    @swaminawale  No, thats ok. I dont know why, but my PowerApps only works with ";", it seems is set to only accept that and no "," (tried simple formulas with that and doesn't work). About the gallery thing, I didn't quite get what you meant 😞 still a newbie at this.

     

    and @BCBuizer  In the app checker it only says 1 error about "Unexpected characters that are used in the formula in an unexpected way". But it doesnt highlight where -.-

     

    Apologies for the long code but I'd really appreciate your help with this! As i have no idea how to fix it and really need to do it 😞

     

  • WorkingRicardo Profile Picture
    878 on at

    captura2.PNGcaptura.PNG

     

    What I meant is this: I'm a newbie at this but how I normally can tell if the code is going to function is when the program highlights in a color the value/function im using. In the code I pasted below is in the plain text color, so yeah, something wrong xD?

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @WorkingRicardo ,

     

    To which property are you trying to apply this formula?

  • WorkingRicardo Profile Picture
    878 on at

    @BCBuizer  Hello again!

    I added that code to a button I added. 

    Btw I erased the final ")" that was on the first line and it seems it must be way: 

    Set(VariableRecord;LookUp(Incidencias; ID = SharePointIntegration.Selected.ID)

    But now I have 7 extra errors. 

    - Unexpected characters, there is a EOF when ParenClose was expected (so i must close the ) but I think it should be in a different part 

    -"VariableRecord" not recognised. So the variable is not created, but dunno why.

    -isBlank has unvalid arguments.

    -Patch has unvalid arguments

    -If has unvalid arguments

    -Number of arguments are unvalid: 2 were expected and 3 were received.

    Any ideas?

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @WorkingRicardo ,

     

    Since for your locale the chaining operator is double semicolon, after the closing brace for the Set function, an extra semicolon should be added:

     

    Set(VariableRecord; LookUp(Incidencias; ID = SharePointIntegration.Selected.ID));;
    If(
     !IsBlank(VariableRecord);
    Patch(
     Incidencias;
     VariableRecord;
     { 
     Cliente:{Value:DataCardValue14.Selected.Cliente};
     Incidencia:{Value:DataCardValue1.Selected.Value};
     Producto:{Value:DataCardValue12.Selected.Producto};
     'Departamento encargado':{Value:DataCardValue3.Selected.Value};
     'Número Documento':DataCardValue13.Text;
     'Personal encargado':DataCardValue4.SelectedItems;
     Estado:{Value:DataCardValue2.Selected.Value};
     'Propuesta resolución':DataCardValue10.SelectedDate;
     'Fecha de resolución':DataCardValue7.SelectedDate;
     'Registro incidencia':DataCardValue5.SelectedDate
     }
    );
    Patch(
     Incidencias;
     Defaults(Incidencias);
     { 
     Cliente:{Value:DataCardValue14.Selected.Cliente};
     Incidencia:{Value:DataCardValue1.Selected.Value};
     Producto:{Value:DataCardValue12.Selected.Producto};
     'Departamento encargado':{Value:DataCardValue3.Selected.Value};
     'Número Documento':DataCardValue13.Text;
     'Personal encargado':DataCardValue4.SelectedItems;
     Estado:{Value:DataCardValue2.Selected.Value};
     'Propuesta resolución':DataCardValue10.SelectedDate;
     'Fecha de resolución':DataCardValue7.SelectedDate;
     'Registro incidencia':DataCardValue5.SelectedDate
     }
    )
    );;
    RequestHide()

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard