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

Patch to SQL database using a collection from SharePoint

I am getting an error on my patch function:

 

The Type of this argument 'Category does not match the expected type 'Text'. Found Type 'Error.

 

Formula:

 

Patch(
'[dbo].[Test]',
Form_Record,
{
Title: Title_value.Text,
Category: First(Category_value.SelectedItems).Value
}

)

 

When I use:

Category: First(Category_value.SelectedItems).Title 

 

It does not complain, but it does not save the data.

 

The Category is from a Sharepoint List.

 

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: Patch to SQL database using a collection from SharePoint

@s1hl3_ukuvuma 

Getting a type of error is not a good thing.  

I'd first start with putting a label on your screen to test with the Texdt property of Category_value.Selected.Title and verify that you are getting an actual value in that.

Then, I'd check over the Items property for the ComboBox to make sure there are no issues with the items or the datasource.

 

See if any of those help you get to the next clue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Super User
Super User

Re: Patch to SQL database using a collection from SharePoint

@s1hl3_ukuvuma 

So, first, can you verify in your SQL table if the value is getting populated or not?  Rather than deduce that it is not there based on what you see in PowerApps, it would be best to look directly at the data to see what is there.  Perhaps you have, but I wanted to state that point.

 

Next, let's alter the fomula just a bit to be a little more accurate:

Patch('[dbo].[Test]',
      Defaults('[dbo].[Test]'),
      {
         AbpmWFRecordID: Form_RecordWFID,  // I assume this is a variable and this is not your primary key
         Title: Title_value.Text,
         Category: Category_value.Selected.Title  // Assume you have no reason for the combobox to be multi-select
      }
)

Let's run the above.  Then look directly at the table in SQL and see what you are getting there.

 

EDIT: fixed typo in formula.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Patch to SQL database using a collection from SharePoint

@s1hl3_ukuvuma 

Getting a type of error is not a good thing.  

I'd first start with putting a label on your screen to test with the Texdt property of Category_value.Selected.Title and verify that you are getting an actual value in that.

Then, I'd check over the Items property for the ComboBox to make sure there are no issues with the items or the datasource.

 

See if any of those help you get to the next clue.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Frequent Visitor

Re: Patch to SQL database using a collection from SharePoint

Hi Randy.

 

Category_value.selected.Title does give me a value.

 

It just didn't look right to me but it works fine.

 

Thanks man

Highlighted
Frequent Visitor

Re: Patch to SQL database using a collection from SharePoint

@RandyHayes 

 

When I log out of the app and log in again, the Text inputboxes patched with First(Category_value.SelectedItems).Title appear to be blank. Which means SQL is not accepting this as a value

 

I have added attachements to give you an indication of what I am trying to achieve

Patch formula:

Patch(
'[dbo].[Test]',
{ID: Blank()},
{
AbpmWFRecordID: Form_RecordWFID,
Title: Title_value.Text,
Category: First(Category_value.SelectedItems).Title

}

Category: First(Category_value.SelectedItems).Value is not working as previously explained.

Highlighted
Super User
Super User

Re: Patch to SQL database using a collection from SharePoint

@s1hl3_ukuvuma 

So, first, can you verify in your SQL table if the value is getting populated or not?  Rather than deduce that it is not there based on what you see in PowerApps, it would be best to look directly at the data to see what is there.  Perhaps you have, but I wanted to state that point.

 

Next, let's alter the fomula just a bit to be a little more accurate:

Patch('[dbo].[Test]',
      Defaults('[dbo].[Test]'),
      {
         AbpmWFRecordID: Form_RecordWFID,  // I assume this is a variable and this is not your primary key
         Title: Title_value.Text,
         Category: Category_value.Selected.Title  // Assume you have no reason for the combobox to be multi-select
      }
)

Let's run the above.  Then look directly at the table in SQL and see what you are getting there.

 

EDIT: fixed typo in formula.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,622)