Hi. I have a problem with Patch function. I want to populate a field (CheckoutTime) with Now() function in an already existing record. In order to do it, I search the record by three fields values:
In other words I want to update the record that has the specific Barcode inserted in an InputText, that has been created today and that has nothing in the field CheckoutTime.
I have written a formula but sometimes it works and sometimes not, because has non delegable function in it:
Patch(checkin_1;LookUp(Filter(checkin_1;IsBlank(DataOraCheckout);Left(Text('Data creazione');10)=Text(Today());Barcode=TextInput1.Text );Barcode=TextInput1.Text); {DataOraCheckout: Now()})
Left is not delegable, also in and Last...
So what I ask is: are there delegable functions that I can use in order to find a record by the value of this three fields? Have you ever been in this situation?
As you're hinting in your last post, you need to verify first that there is a matching record prior to doing the Patch command. For example, populate a Collection first, and check "how it looks".
I have a similar case as yours (not ready-developed yet). But the tricky thing is (I find) is to "check exactly prior to sending the command". My point: My table can be populated from several applications. So theoretically there can endup a missmatch even if I check how the datasource looks via a Collection "just before" sending the Patch command.
Anyone having some idea on how to achieve this best?
Can someone help me, please?
Ok, I have changed my function but my problem still persists...
Patch(checkin_1;LookUp(SortByColumns(checkin_1;"cr392_dataoracheckout";Descending;"createdon";Descending);And(IsBlank(DataOraCheckout);Barcode=TextInput1.Text));{DataOraCheckout: Now()})
But after some tests I've made I think the app in the moment of patching has got the checkin_1 list not updated yet. I try to explain with one example. If I have recently added a new record with the same barcode of one old, it updates the old one, even if it has something in the field DataOraCheckout. In my opinion it can see the new inserted record, so the table it has is not updated. I tried to do a Refresh(checkin_1) before the operation of patching but the problem is still there. Is there another way or function to keep the table updated for the app? Do you think is it possible such a behaviour?
Hi @Mh2
I think your formula has an incorrect syntax in the second element of the Patch() function.
Patch(checkin_1; LookUp(Filter(checkin_1; IsBlank(DataOraCheckout));Barcode=BarcodeScanner4.Value)
{DataOraCheckout: Now()})
I believe that you are trying to Patch an existing record in checkin_1 where DataOraCheckout is blank and the Barcode has the correct value. The Lookup(Filter( is not the correct way to find that record. You should use either First(Filter( or Lookup() but not both. Either of these functions will find the first record that has a blank DataOraCheckout field. You will need an AND (&&) operator to find the record where DataOraCheckout is blank and the barcodes match.
Patch(checkin_1;Lookup(checkin_1; IsBlank(DataOraCheckout)) && Barcode=BarcodeScanner4.Value);{DataOraCheckout: Now()})
I believe all of the functions are delegatable.
I will explain it with an example. Let's take the new formula I have written:
Patch(checkin_1; LookUp(Filter(checkin_1; IsBlank(DataOraCheckout));Barcode=BarcodeScanner4.Value); {DataOraCheckout: Now()})
I have two record on the CDS (one for user) who have the same Barcode value field, but the first one has a blank DataOraCheckout, the second has something in it because user 1 has already scan the barcode. When user 2 scans the barcode, I want to fill DataOraCheckout with his Now() time, but with the formula above, it always update the user 1 record and I cannot understand why. So I think there's something wrong with it.
Hi @Mh2
What is your mean sometimes it works well, sometimes not.
It it not works, is there some warning message or error message and what is the message?
And more information:
Best Regards.
Yumia
mmbr1606
22
Super User 2025 Season 1
stampcoin
19
Michael E. Gernaey
15
Super User 2025 Season 1