cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dennisb88
Resolver I
Resolver I

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 III
Super User III

@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

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@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

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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

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