cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KrypticSloth
Frequent Visitor

The Data Source You're Updating Expects a 'Record' Type and You're Using a 'Image' Type

Trying to send information off to my SharePoint site with the information in my collection, but I'm getting an error stating my SharePoint field is expecting a Record, but I'm sending it an Image. I already checked and my SharePoint is set to Image, so I'm not sure why I'm getting this response. Here is my code I'm having issues with:

ForAll(ExpenseReports, Collect('Expense Report List', {ID: MaxID, Title: Gallery3.Selected.'Expense Report Number', Date: Gallery3.Selected.'Transaction Date', Comment: Gallery3.Selected.'Requestor Comment', UserName: Gallery3.Selected.Requestor, ExpenseName: ExpenseNameInput.Text, ExpenseType: ExpenseTypeInput.Selected.Value, PaymentMethod: PaymentMethodInput.Selected.Value, ExpenseCost: ExpenseCostInput.Text, Receipt: Image1.Image});

 

9 REPLIES 9
WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @KrypticSloth ,

Before I get to the image, you are missing a closing bracket on that (maybe a mistype in the post), you are using Collect (you are making a Collection) rather than Patch to write data to a Date Source (I assume ExpenseReports is a Collection and 'Expense Report List' is your data Source ), and you cannot Patch the ID in SharePoint unless you are giving it the existing actual record ID to update the record (not MaxID which is the one value).

However your question is around the Image which seems to be the same image for all records, can you please detail what it is you are trying to do here with ExpenseReports and how you collect this data.

Hello @WarrenBelz 

I'll admit that I am fairly new to all the syntax of PowerApps and still trying to find what works best for what, and I will admit my application is a bit convoluted. The MaxID shouldn't have been there, it should have been Gallery3.Selected.ID because I want reference to the specific item these line items are on. 

 

I have a Gallery that is being populated with: "Filter(ExpenseReports, !IsBlank(ExpenseName)&& Gallery3.Selected.ID = ThisRecord.ID)", in which I can create a new expense from there and when I'm done creating all the expense's for the expense report in question, I wanted to push that data to my SharePoint data source. For the whole application I can create an expense report, in which I can create multiple expense items attached to that report. When I have all the expenses created, I wanted to loop through them all and send them to my SharePoint site. 

 

If you want more information for the whole application, I will go ahead and explain, but I figured I'd save you the trouble of reading through all of that and just explain what I need assistance with. 

 

Hi @KrypticSloth ,

OK - things are still fairly unclear to me

Are you writing back to update the same records in the Data Source you have collected (you are not writing new records) and if so, are you wanting to update all records from the gallery.

Is ExpenseReports a Collection - if so, do you collect it from 'Expense Report List'

I am more confused at the Gallery Items

Filter(
   ExpenseReports, 
   !IsBlank(ExpenseName)&& 
   Gallery3.Selected.ID = ThisRecord.ID
)

as unless this is a Nested gallery, it is referring to itself in the last line.

Are you using the same Image for all records ? As a start here, if you were patching from the Gallery (and had changed any items in here)

Patch(
   'Expense Report List',
   ForAll(
      Gallery3.AllItems As aPatch,
      {
         ID: aPatch.ID,
         Title: aPatch.'Expense Report Number', 
         Date: aPatch.'Transaction Date', 
         Comment: aPatch.'Requestor Comment', 
         UserName: aPatch.Requestor, 
         ExpenseName: ExpenseNameInput.Text, 
         ExpenseType: ExpenseTypeInput.Selected.Value, 
         PaymentMethod: PaymentMethodInput.Selected.Value, 
         ExpenseCost: ExpenseCostInput.Text, 
         Receipt: Image1.Image
      }
   )
);

any items without aPatch in front of them are assumed not to be in the Gallery (if they are add aPatch. to them). I am also assuming Receipt is an Image column in 'Expense Report List'.

 

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.

MVP (Business Applications)   Visit my blog Practical Power Apps

 

 

 

@WarrenBelz I do apologize that I haven't been exactly clear with everything, I didn't want to have to send everything I had across, but I'll go ahead with that now.

 

So I have 4 Screens for my Application, 2 are galleries, and 2 are forms. I have 'Home Screen', 'Create Expense Report', 'Expense Report Page', and 'Expense Report Line Item'. In the app, I'm using a data source from SharePoint called 'Expense Report List' and created a collection called ExpenseReports. You are correct to assume that Receipt in the SharePoint is an Image field.

 

On the Home Screen Page, I have a Gallery and an option to create a new report, which will go into the Create Expense Report screen. Here is what I have for this page:

Gallery: 
Sort(Filter('Expense Report List', !IsBlank('Expense Report Number') && Requestor = User().FullName),ID, Descending)

Create Expense Report: 
Set(LastScreen, "Home Screen");NewForm(Form2);Navigate('Create Expense Report', ScreenTransition.Cover);ClearCollect(ExpenseReports, {ID: 0, Title: "", Date: Today(), Comment: "", UserName: "", ExpenseName: "", ExpenseType: "", PaymentMethod: "", ExpenseCost: "", Receipt: ""});If(CountRows('Expense Report List') > 0, Set(MaxID, Max('Expense Report List', ID) + 1), Set(MaxID, 1042))

Home Screen: https://i.imgur.com/wWsF5Kp.png

 

On the Create Expense Report page, I have a form that you can fill out the Report Name, Transaction Date, and the Requestor Comment to the manager about this report, if they have one. From there, I have an option to cancel, which goes back to the home page and resets the form, or a "Create" button, which will create the main expense report with the following information:

Create Expense Report Screen: https://i.imgur.com/zTNxXxy.png

Create: Set(LastScreen, "Create Expense Report");Collect(ExpenseReports, {ID: MaxID, Title: ReportNameInput.Text, Date: DateValue(DateValue3), Comment: RequestorComment.Text, UserName: Requestor.Text});SubmitForm(Form2);Navigate('Expense Report Page', ScreenTransition.Cover)

 

Once that is done, it will take you to Expense Report Page, which you will now be in that gallery-selected item. On this page, at the top it will show the information on the specific Expense Report you're on, at the bottom there is a Gallery that will display the current Expenses you have attached to this Expense Report, and give you the option to create a new expense, as well as submit the entire report. Each item at the top there is a switch statement to describe how the data is being filtered in, from the Create Expense page or from the Home Page, as the home page you can go into the specific report as well. I'll show in example here:

Expense Report Page: https://i.imgur.com/S3HtqgW.png

Expense Report Info: Switch(LastScreen, "Home Screen", Gallery3.Selected.'Expense Report Number', "Create Expense Report", Form2.LastSubmit.'Expense Report Number', "New Line Item", Gallery3.Selected.'Expense Report Number')

Gallery Information: Filter(ExpenseReports, !IsBlank(ExpenseName)&& Gallery3.Selected.ID = ThisRecord.ID)

Submit Button information (Currently working on so might not be the same as before): ForAll(ExpenseReports, Collect('Expense Report List', {ID: Gallery3.Selected.ID, 'Expense Report Number': Gallery3.Selected.'Expense Report Number', TransactionDate: Gallery3.Selected.TransactionDate, RequestorComment: Gallery3.Selected.RequestorComment, Requestor: Gallery3.Selected.Requestor, ExpenseName: ExpenseNameInput.Text, ExpenseType: ExpenseTypeInput.Selected.Value, PaymentMethod: PaymentMethodInput.Selected.Value, ExpenseCost: ExpenseCostInput.Text, Receipt: Image1.Image});

 

Right now I don't have the ability to go back into a created expense, but when I do I think I'll be adding a switch statement there as well to see if I need to pull the information and fill the expense page to be able to edit it or if it's a new expense or not. Either way, on the Expense Report screen, you have the ability to create a new expense which takes you to the Expense Line Item screen. On here, It gives you the option to create an Expense Name, upload an image of your receipt, give you a drop down menu of choices for Expense Type, give you another drop down for your payment method (Not fully implemented but a "Default" choice was placed in for the meantime), and an Expense Cost. Once you're done filling out that information, there is an option to Cancel and go back to the Expense Page, or Submit the expense to the expense report. This page looks like the following:

 

Expense Line Item Screen: https://i.imgur.com/81x8EOw.png

Submit: Collect(ExpenseReports, {ID: Gallery3.Selected.ID, Title: Gallery3.Selected.'Expense Report Number', Date: Gallery3.Selected.TransactionDate, Comment: Gallery3.Selected.RequestorComment, UserName: Gallery3.Selected.Requestor, ExpenseName: ExpenseNameInput.Text, ExpenseType: ExpenseTypeInput.Selected.Value, PaymentMethod: PaymentMethodInput.Selected.Value, ExpenseCost: ExpenseCostInput.Text, Receipt: Image1.Image});ResetForm(Form1);

 

Once that's submitted, it creates a new item in the Expense Report screen's gallery with the new collected information, and from there, once I submit all the expenses, I want to submit the entire report and send that over to the SharePoint site, but that's where I'm running into this issue I came to the forum about. I'm open to all forms of criticism on this because, as I said before, I'm still very new to PowerApps and how everything works, and just want to learn and improve on my skills. If there are any suggestions to make this smoother or anything, please feel free to let me know as well. I believe this is all the information I have on this, but if you need anything else, I'll be more than happy to answer the questions to make sure I can get this working. 

Hi @KrypticSloth ,

This has morphed from a basic question on patching an Image field to an in-depth analysis of a process flow and to be honest, I do think I can solve it for you without mapping the whole thing out and possibly creating a model. Are we able to concentrate on your posted question - you should be able to Patch an image to an image column - what is stopping you from doing this ?

When I try to do a patch I get: "The type argument 'field_2' does not match the expected type 'Record'. Found type 'Text'. and I'm not sure what 'field_2' is supposed to be. 

@KrypticSloth ,

That is a different issue to your Image question - you obviously created you list by importing an Excel sheet (not a good idea as the underlying names of the fields remains at field_xx) and you cannot create an Image column that way, so it must be another field you are having the issue with. If you select each field in your List Settings and then look the end of the URL at the top, you will see the "actual" field name.

@WarrenBelz 

That is just the error I'm getting when trying to run a patch instead of a collect. I found it was related to an orphaned collection that I created while testing things called "TestCollection" which had a field_2. I didn't pull this from excel because I'm not using excel only the sharepoint page. Only issue is TestCollection is gone now (I had a ClearCollect on the homescreen when it was visible that I got rid of), but I'm still getting the field_2 error with: 

 

ForAll(ExpenseReports, Patch('Expense Report List', Gallery3.Selected, {'Expense Report Number': Gallery3.Selected.'Expense Report Number', TransactionDate: Gallery3.Selected.TransactionDate, RequestorComment: Gallery3.Selected.RequestorComment, Requestor: Gallery3.Selected.Requestor, ExpenseName: ExpenseNameInput.Text, ExpenseType: ExpenseTypeInput.Selected.Value, PaymentMethod: PaymentMethodInput.Selected.Value, ExpenseCost: ExpenseCostInput.Text, Receipt: Image1.Image})

 

I checked the list settings and there is nothing by the name of field_2 in the collection I'm trying to patch: List Settings

 

@KrypticSloth ,

Did you look at the end of the top URL as I suggested - I just want to make sure there is no field with this "original" name. Whether a collection or the list, the field name must have come from a list somewhere containing that field name. The Error is that field_2 in your collection is Text and that it is expecting a Record in your list - you need to find out which field this is as I cannot do that from here. Did you look in your collection for the field names there ?

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,200)