Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Collecting a Choice Field answer and Updating SharePoint List

Like (1) ShareShare
ReportReport
Posted on 20 Sep 2024 07:47:40 by 46
Hello!  I am close to figuring out this expense report app but have run into a couple of issues and really need some help.
 
I have a form to collect the parent information from an Invoice (Datasource = SharePoint List1): InvoiceEntryForm
I then have a Gallery that collects the child items from that Invoice (Datasource = SharePoint List2): LineItemGallery
The line items of the gallery are added to a collection:
ExpenseCollection = ClearCollect(ExpenseCollection, {EventName: "", ExpenseTypeCollect: "", ItemCost: 0, BusinessUnit: "", CostCenter: ""});
 
When I Submit...
  1- the form submits - SubmitForm(InvoiceEntryForm)
  2 - OnSuccess of the Form submission, the collection is patched: 
ForAll(ExpenseCollection, If(!IsBlank(EventName),Patch(Datasource2, Defaults(Datasource2),
{'Event Name': EventName, 'Item Cost': ItemCost, BusinessUnit: BusinessUnit, 'Cost Center': Value(CostCenter), MasterID: InvoiceEntryForm.LastSubmit.ID})))
 
I'm having issues with the Expense Type field.
 
Expense Type:
Items: Choices(Datasource2.ExpenseType)
Default: ThisItem.ExpenseTypeCollect
In my SharePoint list this is set up as a Choice field.
While there does not seem to be an issue with adding it to the collection, I cannot for the life of me get it added to the patch.   
When I add 'Expense Type': ExpenseTypeCollect, the App Checker tells me that "The type of this argument 'ExpenseType' does not match the expected type 'Record'. Found type 'Text'."
I have tried: 
'Expense Type': ExpenseTypeCollect.Value
'Expense Type': ExpenseTypeCollect.Selected.Value
'Expense Type': ExpenseTypeCollect.Text
'Expense Type': Value(ExpenseTypeCollect)
 
 
Thanks in advance for any help you can provide!
 
Categories:
  • Verified answer
    Jukiejan Profile Picture
    Jukiejan 46 on 20 Sep 2024 at 15:57:54
    Collecting a Choice Field answer and Updating SharePoint List
    Thank you scalca!  Your answer was so close it got me where I needed to be!!!  Thank you very much for your help.
     
    I had to change the ClearCollect to:
    ExpenseTypeCollect: drpExpenseType.Selected.Value instead of ExpenseTypeCollect: ""
     
    I then went back into the OnSuccess and changed the patch to:
    'Expense Type': {Value:  ExpenseTypeCollect}
     
    It would not accept the "." in the patch, but this worked!
  • Suggested answer
    scalca Profile Picture
    scalca 230 on 20 Sep 2024 at 12:32:38
    Collecting a Choice Field answer and Updating SharePoint List
    the error message tells you that expected type must be 'Record' and that's what you need to patch
     
    try with
    'Expense Type': {Value:  ExpenseTypeCollect.Selected.Value}
     
     

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,654

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,440

Leaderboard
Loading started
Loading complete