I have a disabled textfield in a PowerApp, which needs to show the ID of the item the user is going to create through my PowerApp.
I have two lists on SharePoint.
The first list is called "ID Config". The list consists of a single element. This element contains an ID in a field called "Deviation_ID".
The second list contains Deviations. Deviations is created through the Power App, and the next-in-line Deviation_ID is assigned to the Deviation the user is creating.
Each time a user opens the Deviation screen in my PowerApp, the ID in ID Config is counted up, once, using this code on the "OnVisible" property:
If(Connection.Connected,
UpdateContext({DeviationID:Text(Value(First('ID Config').Deviation_ID+1),"00000")});
Patch(
'ID Config',
First('ID Config'),
{Deviation_ID:DeviationID}
), Select(Button2)
);
However, sometimes the ID fetched is being reset to "00001", instead of counting up once. Meaning the ID fetched from the list is just 0.
Am I missing something, that causes a fail when fetching the current ID from the ID Config list?
This here: If(Connection.Connected, UpdateContext({DeviationID:Text(Value(First('ID Config').Deviation_ID+1),"00000")
Sometimes connections drop out for a split second or data doesn't get loaded. Set a timer to wait until the Deviation_ID has time to load. Or even better add in a label with the value of .Deviation_ID. And set your function to use the label's text instead of pulling from the loaded data.
I had a lot of problems with data not getting submitted because I had the edit forms set to Gallery.Selected. When I switched to using variables to hold the data all those problems went away.
If this is gathered from a gallery in an edit form, setup a variable which holds the gallery items data and use that to display your information. It works better. E.G. Set(_MyVariable, ThisItem) or to Gallery1.Selected