cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dennisb88
Helper V
Helper V

Patch a GUID from a collection to a SharePoint List

Hi All,

 

I'm trying to work with a GUID that I've saved in a collection.

I do that with the follow code:

Collect(COLRefID,{RefID:Text(GUID())})

When I want to patch a couple of input field from my App to the SharePoint list, I want to use the generated GUID from my collection (And use the same GUID in a later process in my app).

 

I've created the follow patch code to achieve my goal, but something is not right:

Patch('Item Request',Defaults('Item Request'),{'Item number':TXT_NewItemNumber_1.Text,'Item name':TXT_NewItemname_1.Text,Division:DR_DivisionSelect_1.SelectedText.Value,Category:DR_ProductSelect_1.SelectedText.Value,RefID:COLRefID.RefID})

 

I've got the following issue:

The type of this argument 'RefID' does not match the expected type 'Text'. Found type 'table'.

 

What I'm doing wrong?

When I use the follow command (without the collection option) it's working fine, but I need the same GUID (RefID) in the next step of my app.

Patch('Item Request', Defaults('Item Request'),{'Item number':TXT_NewItemNumber_1.Text,'Item name':TXT_NewItemname_1.Text,Division:DR_DivisionSelect_1.SelectedText.Value,Category:DR_ProductSelect_1.SelectedText.Value,RefID:Text(GUID())})

 

Is there someone who know what I'm doing wrong/ how to fix this?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@dennisb88 

A collection is a table.  If you are only storing one value in your collection, then consider using a variable instead of a collection as you don't need a table for it.

 

To correct the problem you have now, you can change your formula to the following:

Patch('Item Request',
    Defaults('Item Request'),
    {'Item number':TXT_NewItemNumber_1.Text,
     'Item name':TXT_NewItemname_1.Text,
     Division:DR_DivisionSelect_1.Selected.Value,
     Category:DR_ProductSelect_1.Selected.Value,
     RefID:First(COLRefID).RefID
    }
)

 

To move away from the collection for this, simply change your collection to a variable:

Set(varRefID: Text(GUID()))

Then your Patch formula would be the following:

Patch('Item Request',
    Defaults('Item Request'),
    {'Item number': TXT_NewItemNumber_1.Text,
     'Item name': TXT_NewItemname_1.Text,
     Division: DR_DivisionSelect_1.Selected.Value,
     Category: DR_ProductSelect_1.Selected.Value,
     RefID: varRefID
    }
)

 

Also notice in the above formulas that I replaced the SelectedText with Selected.  SelectedText is a deprecated property and should not be used.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@dennisb88 

A collection is a table.  If you are only storing one value in your collection, then consider using a variable instead of a collection as you don't need a table for it.

 

To correct the problem you have now, you can change your formula to the following:

Patch('Item Request',
    Defaults('Item Request'),
    {'Item number':TXT_NewItemNumber_1.Text,
     'Item name':TXT_NewItemname_1.Text,
     Division:DR_DivisionSelect_1.Selected.Value,
     Category:DR_ProductSelect_1.Selected.Value,
     RefID:First(COLRefID).RefID
    }
)

 

To move away from the collection for this, simply change your collection to a variable:

Set(varRefID: Text(GUID()))

Then your Patch formula would be the following:

Patch('Item Request',
    Defaults('Item Request'),
    {'Item number': TXT_NewItemNumber_1.Text,
     'Item name': TXT_NewItemname_1.Text,
     Division: DR_DivisionSelect_1.Selected.Value,
     Category: DR_ProductSelect_1.Selected.Value,
     RefID: varRefID
    }
)

 

Also notice in the above formulas that I replaced the SelectedText with Selected.  SelectedText is a deprecated property and should not be used.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thanks @RandyHayes ,

 

That's helping! I've changed it to a variable and it's working like a charm now!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,239)