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 to a choice colu...
Power Apps
Unanswered

Patch to a choice column in SPO

(0) ShareShare
ReportReport
Posted on by 257

I have a repeating table that adds the data to a collection, this collection then sends the data to a SPO list.  One of these fields is a Choice field in SPO.  This is my ForAll code

 

ForAll(
 OtherIn,
 If(
 (A1_Amount >= 1),
 (Patch(
 'GA-OtherInPage',
 Defaults('GA-OtherInPage'),
 {
 A1_Amountbeforetaxes_Clmn: A1_Amount,
 'A1_GST/HSTTotalPaid_Clmn': A1_GSTHST,
 'A1_PST/QSTTotalPaid_Clmn': A1_PSTQST,
 'A1_Project/Fund_Clmn': A1_ID,
 'A1_Project/Fundiption_Clmn': A1_Description,

 //A1_AccountCode_Clmn:{Value:A1_AccountCode}
 //A1_AccountCode_Clmn: A1_AccountCodeInput.Selected,

 A1_Locn_Clmn: A1_Loc,
 A1_Dept_Clmn: A1_Deprt,
 A1_DeptProg_Clmn: A1_DeprtProgramCode,
 FormID: First(
 Sort(
 'Master List Form',
 ID,
 Descending
 )
 ).ID
 }
 ))
 )
);

 

 

the issues is around the 

//A1_AccountCode_Clmn:{Value:A1_AccountCode}
//A1_AccountCode_Clmn: A1_AccountCodeInput.Selected,

 

all other fields get submitted correctly but this one.  In SPO the column it set to accept values manually, and in Power Apps its complaining about requiring a record vs text entry.  The Text value being the items in the collection. I've tried a few suggestions in from the forms but I think my code and method is a bit different from the solutions people have suggested.

 

Falling short of converting the SPO column to a text field and have the items pull from somewhere else, i would like to find a way to send this collection data to SPO.

 

Any help is appreciated.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @kilaj1 ,

    Firstly, the below may not be the answer, but I will first post a structure that will patch your SP list enormously quicker

    With(
     {wID: Last('Master List Form').ID},
     Patch(
     'GA-OtherInPage',
     ForAll(
     Filter(
     OtherIn,
     A1_Amount >= 1
     ) As aPatch,
     {
     A1_Amountbeforetaxes_Clmn: aPatch.A1_Amount,
     'A1_GST/HSTTotalPaid_Clmn': aPatch.A1_GSTHST,
     'A1_PST/QSTTotalPaid_Clmn': aPatch.A1_PSTQST,
     'A1_Project/Fund_Clmn': aPatch.A1_ID,
     'A1_Project/Fundiption_Clmn': aPatch.A1_Description,
     A1_AccountCode_Clmn:{Value: aPatch.A1_AccountCode},
     A1_Locn_Clmn: aPatch.A1_Loc,
     A1_Dept_Clmn: aPatch.A1_Deprt,
     A1_DeptProg_Clmn: aPatch.A1_DeprtProgramCode,
     FormID: wID
     }
     )
     )
    );

    Next this code

    A1_AccountCode_Clmn:{Value: aPatch.A1_AccountCode}

    is correct assuming

     

    • A1_AccountCode_Clmn is a (single) Choice column in 'GA-OtherInPage'
    • A1_AccountCode in OtherIn is a Text field

    Is any of this not true ?

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • kilaj1 Profile Picture
    257 on at

    Thanks for the reply, I will try that code out, "aPatch" is that new? never tried that before.

    A1_AccountCode_Clmn is a (single) Choice column in 'GA-OtherInPage'

    A1_AccountCode in OtherIn is a Text field

    Is any of this not true ?

    A1_AccountCode_Clmn is a single choice column in a SharePoint list

    A1_AccountCode, in the context of my code is from the collection GA-OtherIn

     

    When I tried a similar code in mine I got an error, "expected type record, found type error."

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @kilaj1 ,

    aPatch (you can call it whatever you want) is a disambiguation operator, which is probably not necessary, but I always use to make it clear that the value is coming from the Collection. If the code does not work, go to View > Collections > OtherIn (or is it GA-Otherin - please confirm) and see what is in the field A1_AccountCode

  • Yock Profile Picture
    45 on at

    Actually the choices is a object type column, so if u want to save the choice type, u need to get items' choice number n choice text, it's the right way
    choice type like that:
    {

    choices num:
    choices text:

    }

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Yock you are confusing a choice column with a lookup column

  • kilaj1 Profile Picture
    257 on at

    The code didn't work unfortunately, this is what's in the A1_AccountCode within the Collection

    kilaj1_0-1659013648560.png

    The SPO library, GA-Otherin, looks like this

    kilaj1_2-1659013919207.png

    This is the column in SPO where the data gets patch to

    kilaj1_1-1659013761170.png

     

     

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @kilaj1 ,

    We need to get down to basics here as the code

    A1_AccountCode_Clmn: {Value: aPatch.A1_AccountCode}

    will write the value in the Text field A1_AccountCode in the Collection OtherIn to a new record in the Choice Field A1_AccountCode_Clmn in the List 'GA-OtherInPage' providing: -

    • Those are the correct names for both the fields and the list and collection (I see OtherIncome mentioned)
    • The Choice field is a single choice in your list.

    Firstly, are you getting any error on the code or is it simply not writing the data ?

    Also can you please do what I asked before and post the column in your collection under View > Collections

  • Yock Profile Picture
    45 on at

    Yock_0-1659406818047.pngYock_1-1659406830482.pngYock_2-1659406845968.png

    Yock_3-1659406859964.png

    For my try is fine, that is go way to save data i think, every choice has items id.

    Yock_5-1659407364267.png

     

    Another good way is use choices function

     

  • kilaj1 Profile Picture
    257 on at

    sorry for the delay.  I wasn't getting an error, it would write data back to SPO but it would duplicate the data to the first choice. 

     

    "will write the value in the Text field A1_AccountCode in the Collection OtherIn to a new record in the Choice"

     

    This got me thinking and I ended up changing the field type in SPO to a text field.  This fixed the issue, was a little annoying to go back and change all the patches i had but it worked in the end.  Thanks!

  • kilaj1 Profile Picture
    257 on at

    wouldn't that explicitly patch it to choice 2?

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