Hi C-Papa,
Below is the code I am using. The colLipInspections collection contains some lip inspections that were created when the app was offline. This code runs when the app is online again. So I want to create the lip inspections online using the data stored offline. When the lip inspection record is created, a post operation sync plugin runs which creates the child station records. The next part of the code is where I am trying to update the child records with the offline child station data. However, the child records don't seem to be there online when the patch creating the lip inspections returns in the app. Hope that makes sense.
ClearCollect(colTempLipInspId, {OnlineLipInspID: "", OfflineLipInspID: ""});
ForAll(
Filter(colLipInspections, CreatedOffline = true),
Collect(colTempLipInspId,
{OnlineLipInspID: Patch('Inspections (Lip)', Defaults('Inspections (Lip)'),
{'Inspection Date': cqms_inspection_date,
'Operating At': LookUp('Mine Sites', 'Mine Site' = OperatingAtMineSiteGUID),
'Operating Machine': LookUp(Machines, Machine = OperatingMachineGUID),
Lip: LookUp(Lips, Lip = LipGUID)
} ).'Inspection (Lip)', OfflineLipInspID: LipInspectionGUID}
);
);
ForAll(colTempLipInspId,
ForAll(Filter(colLipInspectionStationItemsNose, LipInspectionGUID = GUID(OfflineLipInspID)),
UpdateIf('Station Items (Lip Inspection)', 'Lip Inspection'.'Inspection (Lip)' = GUID(OnlineLipInspID)
&& Station = ThisRecord.Station && 'Station Type' = ThisRecord.'Station Type'
&& 'Action Item'.'Action Item' = ThisRecord.'Action Item'.'Action Item'
,
{'Current Profile': cqms_tip_profile,
'Recommended Wear': cqms_recommended_wear,
'Replace?': cqms_replace,
'Locking Kit Action': cqms_locking_kit_action,
'Additional Notes': cqms_additional_notes,
sys_top_wear_base64: cqms_sys_top_wear_base64,
sys_side_wear_base64: cqms_sys_side_wear_base64,
sys_shroud_base64: cqms_sys_shroud_base64,
'Shroud Image': cqms_shroud_image,
'Top Wear Image': cqms_top_wear_image,
'Side Wear Image': cqms_side_wear_image
});
);
);