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?
Solved! Go to Solution.
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,
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'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!
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,
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
188 | |
56 | |
50 | |
37 | |
36 |
User | Count |
---|---|
270 | |
91 | |
82 | |
76 | |
75 |