web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch SharePoint List ...
Power Apps
Unanswered

Patch SharePoint List choice column with a button

(0) ShareShare
ReportReport
Posted on by

I am trying to use a button to patch to a sharepoint list choice column. I want the button on select to patch a determined value to the list. The choices are "Draft" and "Finial".  I added a line to my collection and my patch has LineDraft:"Draft"

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

    @kingy61422 

    Without knowing more specifics about your scenario. Your formula would be similar to the following:

    Patch(yourDataSource, {ID: IDofRecordToPatch, ChoiceColumnName: {Value: "Draft"}})

     

    I hope this is helpful for you.

  • kingy61422 Profile Picture
    on at

    After testing the patch doesn't capture the choice, my choice column name is "Draft". My data source for my form is ExpenseDetails, for my form OnSuccess will Patch(ExpenseDetails) and Patch( ExpenseMaster, LookUp(ExpenseMaster,ID=Form1.LastSubmit.ID). I have my button also submit the form. Is there any other information you need to help?

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @kingy61422 

    Yes - what is your submit function formula?  It should only be: SubmitForm(Form1)

     

    What are you "patching" to ExpenseDetails in your OnSuccess?

     

    Is it that you are trying to update a Choice column in the ExpenseMaster list?

     

    It is not making sense that your ID of your ExpenseDetails and the ID of the ExpenseMaster would be the same (as you are indicating in the LookUp formula)

     

  • kingy61422 Profile Picture
    on at

    My submit function is: SubmitForm(Form1)

    This is what I am patching to ExpenseDetails.

    kingy61422_0-1664463676533.png

    I'm using LookUp so I can reference ExpenseMaster and ExpenseDetails. The ID of ExpenseMaster is the MasterID for ExpenseDetails.

    kingy61422_1-1664463739057.png

    I'm trying to update the choice column in ExpenseMaster when I select my button

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @kingy61422 

    To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  ForAll is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    Your formula and scenario is not making sense!  You have stated that the datasource for your form is ExpenseDetails - Yet, you are adding many records to the ExpenseDetails list manually with a Patch.  What is the form for??

     

    Next, if you have many expense details records, the ID of those records is NEVER going to match the ID of the ExpenseMaster record accurately!  

     

    Your ExpenseDetails record needs to have a MasterID column in it that would contain the ID of the ExpenseMaster record ID.

     

    What is ExpenseCollection and where is that coming from?

  • kingy61422 Profile Picture
    on at

    Sorry, my datasource for my form is ExpenseMaster. The form is to record a report. I have a MasterID column in ExpenseDetails and ExpenseCollection is coming from a gallery for repeating tables.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @kingy61422 

    That is more like it!!

     

    So, you don't need the collection!  You have a gallery - it is a table of data.  Just use that!

     

    What I am not understanding is where does this formula come into play?

    RandyHayes_0-1664468520285.png

    If your form is for the ExpenseMaster records - why are you Patching the datasource again??  Are you not submitting your form?

     

  • kingy61422 Profile Picture
    on at

    The LookUp is to put data entries on the same line without having multiple lines. When I submit the form it goes to ExpenseDetails. ExpenseMaster is the form while ExpenseDetails has the details from the form. I patch certain details to the ExpenseMaster so I can have gallery view of those certain items and to filter the gallery.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @kingy61422 

    Yes, I understand the scenario completely. This is not uncommon.

     

    But, your explanation of what is what is not matching!  You are stating that your form is for ExpenseMaster, yet you just stated that "When I submit the form it goes to ExpenseDetails" - That is not possible if your form is for ExpenseMaster!

     

    So, since I am more than intimately familiar with the process...I will just tell you what it should be.

     

    Your Form is set to ExpenseMaster.  This is the master record for the details.

    You will submit the form with a SubmitForm function.  There is no need for doing any other Patch to the ExpenseMaster list.  That is why you have the form!

     

    In your OnSuccess action of the Form, you will have a Patch statement to write the ExpenseDetail records into your ExpenseDetails list...from your gallery - not from a collection.  The collection only produces a tremendous amount of extra work for you to have to go through.  Your gallery is the source of the data.

     

    This makes your OnSuccess action more like this:

    Patch(ExpenseDetails,
     ForAll(yourGallery.AllItems,
     {ID: ID,
     Title: Self.LastSubmit.Title,
     MasterID: Self.LastSubmit.ID,
     ChalkNumber: controlNameInGalleryThatHoldsThisValue.Text, // see details below
     TOT: controlNameInGalleryThatHoldsThisValue.Text, // see details below
     ...etc..
     }
     )
    )

     

    When you use a gallery for "line/child items" the gallery becomes the source of the data.  There is no need to do actions in the gallery to copy control data into the collection - it's just extra work.

    Each control in the gallery will have the associated value that you need to write.

    In the event that there is no particular control in the gallery, but the column is needed (i.e. ID), then make sure your base collection for the Gallery includes that column, and then just reference it in the ForAll record schema.

     

    Your base collection for the Gallery should be based on:

        Filter(ExpenseDetails, MasterID=yourMasterFormRecord.ID)

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard