Ok @Anonymous lets then begin to clarify things about what you want to achieve.
here is the code of your Journey Detail Screen:
If(
Connection.Connected,
Patch(
Journeys,
Defaults(Journeys),
{
cre08_journey_id:Text(GUID()),
cre08_name:TextInput2.Text,
cre08_companyid:TextInput3.Text,
cre08_driverpmid:TextInput4.Text,
cre08_journeystartdateandtime:DatePicker1.SelectedDate+
Time(Value(ddHour.Selected.Value),Value(ddMinute.Selected.Value),0,0),
'Route ID Lookup': LookUp(Routes,Route=GUID(TextInput8.Text)),
'Bus ID Lookup':LookUp(Buses,Bus=GUID(TextInput7.Text))
}
),
Collect(
JourneyColletion,
{
cre08_journey_id:Text(GUID()),
cre08_name:TextInput2.Text,
cre08_companyid:TextInput3.Text,
cre08_driverpmid:TextInput4.Text,
cre08_journeystartdateandtime:DatePicker1.SelectedDate+
Time(Value(ddHour.Selected.Value),Value(ddMinute.Selected.Value),0,0),
cre08_routeid:LookUp(RouteCollection,Route=GUID(TextInput8.Text)),
cre08_busid:LookUp(BusCollection,Bus=GUID(TextInput7.Text)),
cre08_routename:ComboBox4.Selected.Name
}
);
SaveData(JourneyColletion,"Saveitemstokeep");
);
As I can understand here. You want to save the journey details into data source Journeys if the app has connection. Otherwise, it is saved in JourneyCollection if the app has not connection.
Then, in the next screen, you want to modify the end date of the journey, and again, if you have connection, it is modified in the online data source Journeys, and if don't you want to modify it in your offline collection JourneyCollection. Am I right until here?
If it is like I am supposing. The problem here is that in the first screen (Journey Detail Screen) you collect one record into your data source or your offline collection. Then, in the next screen, you modify it by adding one new field with the end date.
Here is the point:
- With connection, you add a new record to Journeys, and in the next screen then modify the field cre08_journeyenddateandtime of that record. I supose your data source has an existing field with that name.
- However, when you don't have connection, you first store the new record into JourneyCollection offline and then try to modify it by adding an end date in the field cre08_journeyenddateandtime. The thing here is that when you first collected the item in JourneyDetails page into this JourneyCollection, you did not specify a field named cre08_journeyenddateandtime so it is not possible to alter that field value in the second screen, as this field does not exist.
The solution? Easy, just add this field in the code of the JourneyDetail Screen so when you collect into JourneyCollection the values of ID, name, start date... the field cre08_journeyenddateandtime is also created with a blank value so it can be modified after. Here is the added change.
If(
Connection.Connected,
Patch(
Journeys,
Defaults(Journeys),
{
cre08_journey_id:Text(GUID()),
cre08_name:TextInput2.Text,
cre08_companyid:TextInput3.Text,
cre08_driverpmid:TextInput4.Text,
cre08_journeystartdateandtime:DatePicker1.SelectedDate+
Time(Value(ddHour.Selected.Value),Value(ddMinute.Selected.Value),0,0),
'Route ID Lookup': LookUp(Routes,Route=GUID(TextInput8.Text)),
'Bus ID Lookup':LookUp(Buses,Bus=GUID(TextInput7.Text))
}
),
Collect(
JourneyColletion,
{
cre08_journey_id:Text(GUID()),
cre08_name:TextInput2.Text,
cre08_companyid:TextInput3.Text,
cre08_driverpmid:TextInput4.Text,
cre08_journeystartdateandtime:DatePicker1.SelectedDate+
Time(Value(ddHour.Selected.Value),Value(ddMinute.Selected.Value),0,0),
cre08_journeyenddateandtime: Blank(),
cre08_routeid:LookUp(RouteCollection,Route=GUID(TextInput8.Text)),
cre08_busid:LookUp(BusCollection,Bus=GUID(TextInput7.Text)),
cre08_routename:ComboBox4.Selected.Name
}
);
Then the formula in your second screen should work properly as the field cre08_journeyenddateandtime already exists.
Also your data source Journeys need to have a field with that name so it can me modified when wanted.
If I am not wrong with your intention here, guess this will work now