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 / Correct OnSelect Synta...
Power Apps
Answered

Correct OnSelect Syntax to update a SharepointList Record in Powerapps

(0) ShareShare
ReportReport
Posted on by 11

Hi all,

 

so I am fairly new to powerapps and I am having a hard time trying to figure out why a record is not being updated when I make changes to it.

Some background first I guess. -

Basically I have a Stationery request list in Sharepoint. It has around 90 columns, one for each time of item that can be ordered. From this I have created a customize form in powerapps.

 

In powerapps I have a few screens(Intro Screen, MonthlyOrdersNew, MonthlyOrdersEdit and ApproversScreen. The intro screen which has a selection of locations(for each house that needs to do a stationary order). When the user clicks on their house, it will take them to either a new form to fill out or a current order to update/approver.  The button uses a variable in the code called varlocid along with a value that is linked to the location they are submitting the form for .  On the new form fields like their  location, who the approver is, and who submitted the form are all automatically filled in. On this new form page is a 3 column sharepointform with the datasource being the sharepoint list that has all 90 or so items that can be ordered along with sliders for the the number of items of each type that can be ordered at anyone time. They fill it out and hit the Submit Order button. This then records the record and returns them back to the IntroScreen. Then because there is now an order in place, a label shows on that location stating there is a current order. If they press on the button now, instead of going to a MonthlyOrdersNew screen, it goes to the MonthlyOrderEdit screen and displays the form using data from that record. It knows to do this via the variable varlocid.

 

The whole form is meant to only ever show them the screens and not the entered data back in sharepoint. I do this via the Launch command to ensure they either go to the IntroScreen or back to our internal homepage.

 

Side Note but probably important. Both SharePointFormNew and SharePointFormEdit(the names I gave to each sharepoint form under new and edit screens) have the datacards for all items and the colums for such things as LocID, Createdby, Location etc and are hidden and they are pulling data across. And I have a second Sharepoint List that has information about approvers, emails for them and the Locations and their associated ID(which varlocid and LocID refer to). And I have in the SharePointFormNew the data source correctly set and in the SharePointFormEdit I have the data source and the Item set. In the item field I have the following -

"LookUp('Stationary_&_First_Aid_list', LocID=Text(varlocid))"

 

 - This works and shows the record and the data within.

 

The issue I am having is when I am in the MonthlyOrdersEdit screen and I change any of the Items and I want to update the original record I am working in, it will not at all update. 

 

It does not matter if I use UpdateIf, Update, Patch, SubmitForm commands. Nothing wants to update the original form record. 

 

I keep reading about those who use the Gallery function and the usual thing to do is simply use the  SubmitForm command. So in my case I would put SubmitForm(SharePointFormEdit) but this does not work. 

 

So I am wondering if maybe somewhere else in the whole setup I have set something incorrectly. Or I am just doing it all the hard way. I originally also had a comments box for misc orders but that also refused to update the original record when I made changes to it. I tried using in some of the formula after datasource, LocID=Text(varlocid) and this shows the correct ID for that location for that record, but I feel like this is wrong somehow. I feel like I need to be referencing every single column in the list in order for it to update the entire record rather than referencing SharePointFormEdit and the varlocid variable to update it. 

 

Please help.

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MTAppsDev ,

     

    Am not able to understand the whole scenario, but if you use SubmitForm for an Edit form, it will update the record set in Item property. With the formula you are using:

    LookUp('Stationary_&_First_Aid_list', LocID=Text(varlocid))

    is it possible that the varlocid has not been updated to the new created item? You can try and update the variable on SharePointFormNew Form's submitting button:

    Set(varlocid, SharePointFormNew.LastSubmit.LocID)

     

    Best regards,

  • MTAppsDev Profile Picture
    11 on at

    Hi there,

     

    thanks for taking time to reply. 

     

    Some more info - On the App section just below Sharepoint Integration, I have set a global variable. This Set(varlocid, 0). So will that affect what you have suggested? 

    I do not have LocID set globally. I did add it in but it didn't make any difference.

     

    Hopefully below gives more clarity to the flow of things in the app.

    I have attached some images below to show what the app looks like. When a user presses a location it opens up either a new order screen or a edit order screen. The code on the onselect for each location button is as follows-
    "If(LookUp('Stationary_&_First_Aid_list', LocID = "6" && 'Approval Status'=false,true), Navigate(MonthlyOrdersEdit,ScreenTransition.None,{varlocid:6}), Navigate(MonthlyOrdersNew, ScreenTransition.None, {varlocid:6}))". So when they press it, if there is no order in place already, it opens the MonthlyNewOrders screen and they can put their order in. If there is one already, it goes to the MonthlyOrdersEdit screen and displays the order currently active. This is to stop multiple orders being done for the same location and additionally if the orders are closed during two dates they can't put an order in. 

     

    And as mentioned above, when it goes to the MonthlyOrdersEdit screen it pulls all data correctly. I did have a comments box and it also record just fine and when editing the data was there but I was having issues getting it to write back data to the original record. Which brings me to another question, can you simple via the edit screen submit a form that overrides the original record with new data, i.e. simply replaces everything?

     

    Let me know if there is certain field or controls etc that you want to see what code I have in them. I was trying to find info about which fields must have code in them and what that code is. For example you must have the "data source" set and the "Item" set correctly but it doesnt' look like you must have the Sharepoint Integration functions such as OnNew, OnSave, etc set for things to work. Again thanks for your time.

     

     

     

    Location Select Screen.jpgMonthlyOrdersNew_Screen.jpgMonthlyOrdersEdit_Screen.jpg

  • Verified answer
    MTAppsDev Profile Picture
    11 on at

    Ok Quick Update..... Solved it.

     

    And I would like to say, you wouldn't believe where the issue/fault was, but let's be honest here. I am very new to all of this with no powerapps or coding background. 

     

    Ok so, on each datacard there are various controls of which one is Update. I had the incorrect setting in there. I had it set to the same as if it was on the NewForm screen where it had to be set to a slider that sits in the datacard. The Slider is set to Parent.Default which works fine when you pull the data in but then when you adjust it, that is what updates the data when you do SubmitForm. I did have it working at one stage but I must have undone some changes which reverted it back to a place prior to updating it and I just didn't see it.

     

    Now that I have spotted this I should hopefully be able to add in the Comments box I had before and enable it to update the data when a user makes changes to it.

     

    If you have any other suggestion or tips let me know. Appreciate the help.

     

    Cheers 🙂

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard