cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

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
Highlighted
Community Support
Community Support

Re: Collect a GUID not possible?

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
Highlighted
Frequent Visitor

Re: Collect a GUID not possible?

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?

Highlighted
Super User
Super User

Re: Collect a GUID not possible?

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!

 

Highlighted
Frequent Visitor

Re: Collect a GUID not possible?

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!

Highlighted
Community Support
Community Support

Re: Collect a GUID not possible?

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

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 (7,341)