Hello,
I have an issue with a patch function that seems to work sometimes (100% when I test it) but after it is moved from Test to Prod environment and a end user is using the app it doesn't work.
I can test it with them and it works, but when I go away it doesn't work. I am totally confused by this behaviour.
I have two tables Orders and Containers.
When a container record is being patched as a certain stage in the process, the order the container belongs too needs the quantity field to be updated.
For example an Order needs 4 containers. When a container is assigned to the order, the Total Fitted field on Order is increased by 1.
I also want to check if the order now has all the containers it needs and if there are 0 left to fitted the Order status is updated to Fitted. This also doesn't always happen.
I moved the check if the order has 0 left to do to second screen so that I didn't have 2 functions patching the Order table on the
one button. But this hasn't helped.
On Screen 1 I have the following on a button to save and exit the screen. See the last patch function.
Patch(QPContainers,LookUp(QPContainers,ContainerID = dpdFCContainer.Selected.ContainerID), {'Bladder No':txtFCBladderNo.Text,'Seal No':txtFCSealNo.Text,'Shipping Line':dpdFCShippingLine.Selected.Value, Location:LookUp('QP Locations','Location Name' = lblFCLocationText.Text), 'Container Status':'QP Container Status'.Located});
ForAll(cltFCCameraPics,
Patch(QPContainerPhotos,Defaults(QPContainerPhotos),
{PhotoName:ThisRecord.name, Photo:ThisRecord.pic,ContainerNo:LookUp(QPContainers,ContainerID = dpdFCContainer.SelectedText.Value),Order:LookUp(QPOrders,'Order Ref No'=lblFCOrder.Text)}
)
);
Set(varFCNewToFit,lblFCNewToFitQty.Text);
Set(varFCOrderNo, lblFCOrder.Text);
Set(varFCContainerNo,dpdFCContainer.Selected.ContainerID);
Patch(QPOrders,LookUp(QPOrders,'Order Ref No'=lblFCOrder.Text),
{'Fitted Qty':Value(lblFCNewFittedQty.Text)}
); //To Update the Orders Fitted Qty
If(
// check if there were any errors when the QPOrders was submitted
!IsEmpty(Errors(QPOrders)),
// if true, show any error message
Notify(
Concat(Errors(QPOrders), Column&": "&Message),
NotificationType.Error
),
// else, go to success screen
UpdateContext({ResetFittingCheckbox:true});UpdateContext({ResetFittingCheckbox:false});
Navigate(scnFittedQtySuccess);
)
On screen FittedSuccess I have the following when the button is clicked to save and close the screen.
If(varFCNewToFit in 0,(Patch(QPOrders,LookUp(QPOrders,'Order Ref No' = varFCOrderNo),
{'Order Status':'QP Order Status'.Fitted}
))); //To update the Orders table order status
Any pointers would be appreciated.
Thanks
Rosie