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 / Need help for share po...
Power Apps
Answered

Need help for share point list coding to save data in share point list instead of collection

(0) ShareShare
ReportReport
Posted on by 194

Hello All,

I am working on Template app "Expense Report"

I need help for convert codding from Collection to share point list

Viral21_0-1614928085589.png

Above code for "Save" button. I need to write this code for share point list.

My share point List name: "LineItems". Below is my share point list column.

Viral21_2-1614928191910.png

 

Viral21_1-1614928154679.png

So can anyone help me for that?

 

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

    Hi @Viral21 :

    If you want to replace LineItems with the original LineItems2, the number of formulas you need to modify will probably reach 70-80.For this reason, I really have no way to directly provide you with a complete solution.

    I have two alternatives:

    Solution1: The safest solution is to follow this tutorial to recreate an APP

    Solution2: I'm not sure if this method is useful, but maybe you can try

    Setp1: Delete this formula in OnStart

    ClearCollect(LineItems2,
     {Title: "Meals for day", ID: "11", Date: DateAdd(Now(), -1, Days), Category: "Food & Beverage", Cost: 100, ReportID: Text("1"), Description: "Breakfast, Lunch, Dinner, and Drinks"},
    
     {Title: "Uber to visit Percy", ID: "10", Date: DateAdd(Now(), -29, Days), Category: "Transportation", Cost: 20, ReportID: "2", Description: "Visited Percy to checkup on things"},
     {Title: "Flowers", ID: "9", Date: DateAdd(Now(), -29, Days), Category: "Business Needs", Cost: 40, ReportID: "2", Description: "Striped Carnations"},
     {Title: "Rented projector", ID: "8", Date: DateAdd(Now(), -28, Days), Category: "Business Needs", Cost: 30, ReportID: "2", Description: "Needed projector for presentation"},
     {Title: "Hotel Room", ID: "7", Date: DateAdd(Now(), -24, Days), Category: "Business Needs", Cost: 1400, ReportID: "2", Description: "Hotel Room for my stay"},
    
     {Title: "Dinner", ID: "6", Date: DateAdd(Now(), -13, Days), Category: "Food & Beverage", Cost: 40, ReportID: "3", Description: "Salmon"},
     {Title: "Dinner", ID: "5", Date: DateAdd(Now(), -12, Days), Category: "Food & Beverage", Cost: 40, ReportID: "3", Description: "Steak"},
     {Title: "Hotel Room", ID: "4", Date: DateAdd(Now(), -11, Days), Category: "Business Needs", Cost: 600, ReportID: "3", Description: "Hotel Room for my stay"},
    
     {Title: "Meals", ID: "3", Date: DateAdd(Now(), -5, Months), Category: "Food & Beverage", Cost: 1400, ReportID: "4", Description: "All meals throughout trip"},
     {Title: "Transportation", ID: "2", Date: DateAdd(Now(), -5, Months), Category: "Transportation", Cost: 400, ReportID: "4", Description: "All transportation throughout trip"},
     {Title: "Lodging", ID: "1", Date: DateAdd(Now(), -5, Months), Category: "Business Needs", Cost: 1400, ReportID: "4", Description: "Lodging throughout trip"}
    );

     Step2: Create a SP list named "LineItems2" and add this list to you APP

    Hope that the collection can be replaced with a SP list has the same name

    Best Regards,

    Bof

  • Viral21 Profile Picture
    194 on at

    Hello,

    Actually I go through given document and try to create app but after follow all steps at the end App is not open in Edit mode.

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/expense-report-install

     

    I also concern Power App support team but they told they have issue with given template. So it's not useful

     

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Viral21 :

    Please test my solution2 (I have tested this scenario and it works very well)
    1\Create a SharePoint list (It's name must be LineItems2)

    Column (click to edit) Type
    Title Single line of text
    Date Date and Time
    Category Single line of text
    Cost Number
    ReportID Single line of text
    Description Single line of text

    2\Delete this formula in OnStart

     

    ClearCollect(LineItems2,
     {Title: "Meals for day", ID: "11", Date: DateAdd(Now(), -1, Days), Category: "Food & Beverage", Cost: 100, ReportID: Text("1"), Description: "Breakfast, Lunch, Dinner, and Drinks"},
    
     {Title: "Uber to visit Percy", ID: "10", Date: DateAdd(Now(), -29, Days), Category: "Transportation", Cost: 20, ReportID: "2", Description: "Visited Percy to checkup on things"},
     {Title: "Flowers", ID: "9", Date: DateAdd(Now(), -29, Days), Category: "Business Needs", Cost: 40, ReportID: "2", Description: "Striped Carnations"},
     {Title: "Rented projector", ID: "8", Date: DateAdd(Now(), -28, Days), Category: "Business Needs", Cost: 30, ReportID: "2", Description: "Needed projector for presentation"},
     {Title: "Hotel Room", ID: "7", Date: DateAdd(Now(), -24, Days), Category: "Business Needs", Cost: 1400, ReportID: "2", Description: "Hotel Room for my stay"},
    
     {Title: "Dinner", ID: "6", Date: DateAdd(Now(), -13, Days), Category: "Food & Beverage", Cost: 40, ReportID: "3", Description: "Salmon"},
     {Title: "Dinner", ID: "5", Date: DateAdd(Now(), -12, Days), Category: "Food & Beverage", Cost: 40, ReportID: "3", Description: "Steak"},
     {Title: "Hotel Room", ID: "4", Date: DateAdd(Now(), -11, Days), Category: "Business Needs", Cost: 600, ReportID: "3", Description: "Hotel Room for my stay"},
    
     {Title: "Meals", ID: "3", Date: DateAdd(Now(), -5, Months), Category: "Food & Beverage", Cost: 1400, ReportID: "4", Description: "All meals throughout trip"},
     {Title: "Transportation", ID: "2", Date: DateAdd(Now(), -5, Months), Category: "Transportation", Cost: 400, ReportID: "4", Description: "All transportation throughout trip"},
     {Title: "Lodging", ID: "1", Date: DateAdd(Now(), -5, Months), Category: "Business Needs", Cost: 1400, ReportID: "4", Description: "Lodging throughout trip"}
    );

     

    3\add the SP list to you APP

    2.JPG1.JPG

    4\NewLineItem(Screen)-NewLineItemSaveAndNewButton_2-OnSelect

     

    Collect(LineItems2, {Category: First(DataCardValue26_3.SelectedItems).Value, Cost: Value(DataCardValue27_3.Text), Date: DataCardValue25_3.SelectedDate, Description: DataCardValue29_3.Text, ReportID: SelectedReport2.ID, Title: DataCardValue29_3.Text});
    
    UpdateContext({Defaults: false, DefaultDate: Today(), DefaultTextValue: "1"});
    UpdateContext({Defaults: true, DefaultDate: Today(), DefaultTextValue: ""});
    ClearCollect(DefaultRecord, "")

     

    5\NewLineItem(Screen)-NewLineitemCreateButton_1-OnSelect

     

    Collect(LineItems2, {Category: First(DataCardValue26_3.SelectedItems).Value, Cost: Value(DataCardValue27_3.Text), Date: DataCardValue25_3.SelectedDate, Description: DataCardValue29_3.Text, ReportID: SelectedReport2.ID, Title: DataCardValue29_3.Text});
    
    UpdateContext({Defaults: false, DefaultDate: Today(), DefaultTextValue: "1"});
    UpdateContext({Defaults: true, DefaultDate: Today(), DefaultTextValue: ""});
    ClearCollect(DefaultRecord, "");
    
    Navigate(ViewReport,None)

     

    Best Regards,

    Bof

  • Viral21 Profile Picture
    194 on at

    Hello @v-bofeng-msft 
    Thanks for your support
    I have 2 issue
    1. Category Colum type is choice in SharePoint
    2. ReportID column type is Lookup

    So while I am paste your given code it's through error. Because I am using different datatype.

    ReportID look into other List "Expense"

    And For "Expense" also I have same issue

     

    Viral21_0-1614927148120.png

    My share point List name:  "Expenses"

    Viral21_0-1614927627304.png

    I think now you can understand all scenario. 

    So can you please help me.
    Thank you so much for your valuable feedback 

  • Viral21 Profile Picture
    194 on at

    Hello @v-bofeng-msft 
    I have also attached my current error snap

    Viral21_2-1615220803422.png

    My Category filed Dropdown code: Choices(LineItems2.Category)
    Dropdown works fine

    I think it's help you to find the solution where I am doing wrong
    Thanks In Advance!!

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Viral21 :

    I'm afraid your problem can't be solved in a few sentences, because LineItems2 is quoted in about 80 places in the template. In addition, these places will also be affected by other controls. For example:

    The reason for the error report of the screenshot you provided may be because the data structure of the Category value is defective, but its value is affected by the items property of the control DataCardValue26_3.

    For questions like this, I guess there should be many places.Therefore, if you insist on using the selection column, it will be a very troublesome and time-consuming task. You need to modify the formula yourself according to the prompts of the "App checker".

    If you need me to provide a clear and simple solution,I can only advice you to follow the solution I provided before.

    Best Regards,

    Bof

  • Viral21 Profile Picture
    194 on at

    Hello @v-bofeng-msft 

    Yes I understand the situation.

    Do you have same template in working mode?

     

    If yes, so can you please provide me that template package?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Viral21 :

    I am using this template——

    1.JPG

    Best Regards,

    Bof

  • Viral21 Profile Picture
    194 on at

    Hello @v-bofeng-msft 
    Is it using Sharepoint ?

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Viral21 :

    No.It's data source is a collection.You can follow my solution to make your SharePoint list as the data source.

    In addition, the data structure of this SP list must be consistent with the one in my solution.

    Best Regards,

    Bof

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

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard