cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Collect a GUID not possible?

Wracking my brain here. 

Why on earth can I not Collect a GUID() value?
Example

Collect(colMeasuredStations,
    {
        measurementID: GUID(),
        stationID: GUID(),
        stationName:  "Station " & CountRows(colMeasuredStations) + 1,
        stationDesc: stationDescription_1.Text,
        preWorkFoot: initialMeasFoot_1.Text,
        preWorkInch: initialMeasInch_1.Selected.Value,
        postWorkFoot: " ",
        postWorkInch: " ",
        diffFoot: " ",
        diffInchImp: " ",
        diffInchMetric: " ",
        measurementStartTime: varMeasurementDateTime,
        measurementEndTime: " ",
        measuredBy: User().FullName
    }
)

Results in the error: 
"Incompatible type. The item you're trying to put into a collection has a type that's not compatible with the collection."

Anyone else have this problem?

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @ericonline ,

Where do you initialize the colMeasuredStations collection within your app? Could you please share a bit more about the formula? Just use the Collect() function that you mentioned?

Based on the error message that you mentioned, it seems to tell that you initialized the colMeasuredStations collection some where else, but when you add records into this collection using Collect() function, you provided a incompatible value for correcponding columns in your colMeasuredStations collection.

 

I have made a test on my side, and don't have the issue that you mentioned. Please check if you have provided proper values for corresponding columns in your colMeasuredStations collection.

In addition, please also consider take a try to modify your formula as below:

Collect(
colMeasuredStations, { measurementID: Text(GUID()), /* <-- Modify formula here */ stationID: Text(GUID()), /* <-- Modify formula here */ stationName: "Station " & CountRows(colMeasuredStations) + 1, stationDesc: stationDescription_1.Text, preWorkFoot: initialMeasFoot_1.Text, preWorkInch: initialMeasInch_1.Selected.Value, postWorkFoot: " ", postWorkInch: " ", diffFoot: " ", diffInchImp: " ", diffInchMetric: " ", measurementStartTime: varMeasurementDateTime, measurementEndTime: " ", measuredBy: User().FullName } )

Note: The result the GUID() function returns is a GUID type value. If you initialize your colMeasuredStations collection in some where else, and set measurementID column and stationID column as text value, please consider take a try to convert the GUID type value into a text value uing Text() function.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Isaac_Magnetism
Frequent Visitor

Are you sure it is to do with the GUID?

I am able to collect GUIDs, could it possibly be to do with one of your other variables data type?

I'm not sure it is the GUID.

  • I'm using the ClearCollect function as shown above OnSelect of an "Add" button
  • I have a Gallery set to colMeasuredStations
  • There is an "Edit" button on each line of the Gallery
  • OnSelect of the "Edit" button set to UpdateContext({varEditRecord: ThisItem.measurementID})
  • Then, the DisplayMode of the Textboxes on the selected Gallery item is set to If(ThisItem.measurementID = varEditRecord, DisplayMode.Edit, DisplayMode.Disabled)
  • OnSelect of the "Save" button (no visible), I set varEditRecord to UpdateContext({varEditRecord: Blank()})

I've tried quite a few things to eliminate the red "x"'s, but the culprit seems to be the GUID. When I comment out those two lines, the errors disappear. I've even tried UpdateContext({varEditRecord: " "}) instead of Blank() thinking that was causing the issue. No go. 
Can you see anything in my approach that might be causing the issue?
Thanks!

 

Interesting, I seem to be able to get a variation of this problem to work. I don't think your edit button is causing the issue that seems to be fine.

My set up:
I have a Gallery which Item is a Collection
A new record is added with a button via the OnSelect formula you provided 

Collect(colMeasuredStations,
{
measurementID: GUID(),
stationID: GUID(),
stationName: "Station " & CountRows(colMeasuredStations) + 1,
stationDesc: "",
preWorkFoot: "",
preWorkInch: "",
postWorkFoot: " ",
postWorkInch: " ",
diffFoot: " ",
diffInchImp: " ",
diffInchMetric: " ",
measurementStartTime: varMeasurementDateTime,
measurementEndTime: " ",
measuredBy: User().FullName
}
)

The gallery was full of controls relating to the properties in the collection and the button has the on select formula of:

Patch(colMeasuredStations,Gallery1.Selected,{
        stationDesc: TextInput1_1.Text,
        preWorkFoot: TextInput1_2.Text,
        preWorkInch: TextInput1_3.Text
    }
)

You don't need to add properties you aren't changing such as the GUIDS and the start date.

 

Not sure if this helps as I don't know the exact data types you are working with, but I hope it does!

v-xida-msft
Community Support
Community Support

Hi @ericonline ,

Where do you initialize the colMeasuredStations collection within your app? Could you please share a bit more about the formula? Just use the Collect() function that you mentioned?

Based on the error message that you mentioned, it seems to tell that you initialized the colMeasuredStations collection some where else, but when you add records into this collection using Collect() function, you provided a incompatible value for correcponding columns in your colMeasuredStations collection.

 

I have made a test on my side, and don't have the issue that you mentioned. Please check if you have provided proper values for corresponding columns in your colMeasuredStations collection.

In addition, please also consider take a try to modify your formula as below:

Collect(
colMeasuredStations, { measurementID: Text(GUID()), /* <-- Modify formula here */ stationID: Text(GUID()), /* <-- Modify formula here */ stationName: "Station " & CountRows(colMeasuredStations) + 1, stationDesc: stationDescription_1.Text, preWorkFoot: initialMeasFoot_1.Text, preWorkInch: initialMeasInch_1.Selected.Value, postWorkFoot: " ", postWorkInch: " ", diffFoot: " ", diffInchImp: " ", diffInchMetric: " ", measurementStartTime: varMeasurementDateTime, measurementEndTime: " ", measuredBy: User().FullName } )

Note: The result the GUID() function returns is a GUID type value. If you initialize your colMeasuredStations collection in some where else, and set measurementID column and stationID column as text value, please consider take a try to convert the GUID type value into a text value uing Text() function.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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,054)