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

Patch function Updating the existing record

Hi,

 

I have a code that patch new record and it works. However, when updating the existing record, Department, Room and Activity is not patching. What is wrong with my code?

 

If(varMode = "New",

//Patch the Date, Department, Activity, Room and get the list ID
Set(TempCol, Patch(QAOversightApp, Defaults(QAOversightApp),
{
Date: DataCardValue5_7.SelectedDate,
Department:DataCardValue17_Department_2.Selected.Result,
Activity1:ActivityDD3_2.Selected.Activity,
Room1:RoomDD6_2.Selected.Room
}));
//Update with patch function the attachment 
Patch(QAOversightApp, LookUp(QAOversightApp, ID = TempCol.ID),
{
Date: DataCardValue5_7.SelectedDate,
Department:DataCardValue17_Department_2.Selected.Result,
Activity1:ActivityDD3_2.Selected.Activity,
Room1:RoomDD6_2.Selected.Room

}, Form1_5.Updates);
varMode="Edit", SubmitForm(Form1_5));
Back()

 

Any help is very much appreciated!

 

Regards,

May

6 REPLIES 6
StalinPonnusamy
Community Champion
Community Champion

Hi @mayarnaldo15 

 

Please share the Column/Field type for Department, Room and Activity AND I assume the Data source is Sharepoint

Meanwhile, you can try this If it's Choice field

Department:{Value: DataCardValue17_Department_2.Selected.Result},

 

Hi,

 

Thank you for your reply.

 

Department, Room and Activity is from different Sharepoint list as Text called Department/Room Sharepoint List

mayarnaldo15_0-1634193365992.png

 

and this shown in Powerapps as dropdown

mayarnaldo15_1-1634193419339.png

and save it in Master List in Sharepoint as Text.

 

 

 

Hope this makes it clear 🙂

 

Regards,

May

 

 

 

 
 

 

 

StalinPonnusamy
Community Champion
Community Champion

Hi @mayarnaldo15 

 

If(varMode = "New",

//Patch the Date, Department, Activity, Room and get the list ID
Set(TempCol, Patch(QAOversightApp, Defaults(QAOversightApp),
{
Date: DataCardValue5_7.SelectedDate,
Department:DataCardValue17_Department_2.Selected.Result,
Activity1:ActivityDD3_2.Selected.Activity,
Room1:RoomDD6_2.Selected.Room
}));

//Update with patch function the attachment 
Patch(QAOversightApp, LookUp(QAOversightApp, ID = TempCol.ID),
Form1_5.Updates
)
, SubmitForm(Form1_5))

 

And Set OnSuccess property of the Form1_5 to

Back()

Set OnFailure property of the Form1_5 to

Notify(
    Concat(
        Errors(QAOversightApp),
        Column & ": " & Message
    ),
    NotificationType.Error
)

HI @StalinPonnusamy ,

 

Thank you for this.

 

I tried it. There's no error when saving it in PowerApps but it didn't save the information in Sharepoint List.

 

Regards,

May

Hi @mayarnaldo15 

 

SubmitForm itself should work with attachment as long as the Update property of the Data card is set.

SubmitForm(FormName);

 

If you use Custom Datacard (s) on your form then your Patch command will be 

  1. Patch the Date, Department, Activity, Room and get a list ID
  2. Get the Latest or existing ID
  3. Attachment
//Patch the Date, Department, Activity, Room and get the list ID
Set(TempCol, Patch(QAOversightApp, If(varMode = "New", Defaults(QAOversightApp),LookUp(QAOversightApp, ID = BrowseGallery1.Selected.ID)),
{
Date: DataCardValue5_7.SelectedDate,
Department:DataCardValue17_Department_2.Selected.Result,
Activity1:ActivityDD3_2.Selected.Activity,
Room1:RoomDD6_2.Selected.Room
}
) //Patch
); //Set

//Get the Latest or existing ID
Set(CurrentID, If(varMode = "New", TempCol.ID, BrowseGallery1.Selected.ID));

//Attachment - Update with patch function 
Patch(QAOversightApp, LookUp(QAOversightApp, ID = CurrentID),
Form1_5.Updates
);

 

Note: Make sure to update BrowseGallery1.Selected.ID to ID that you have for an existing records.

 

StalinPonnusamy
Community Champion
Community Champion

Hi @mayarnaldo15 


Please let us know if anything needs on your post. We can help with this.

Please do not forget to give kudos if you find the suggestion helpful or Accept it as a solution if works fine to help other users to find it useful.

Thanks,
Stalin - Learn To Illuminate

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,823)