web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Delegable patch CDS
Power Apps
Unanswered

Delegable patch CDS

(0) ShareShare
ReportReport
Posted on by 24

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:

  • a Barcode taken from an inputText,
  • a Creation date of today (no matter what time), 
  • a CheckoutTime that is blank

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?

I have the same question (0)
  • v-yuxima-msft Profile Picture
    on at

    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:

    delegation-overview

     

     

    Best Regards.

    Yumia

  • Mh2 Profile Picture
    24 on at

    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.

     

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    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. 

  • Mh2 Profile Picture
    24 on at

    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?

  • Mh2 Profile Picture
    24 on at

    Can someone help me, please?

  • jkh Profile Picture
    2 on at

    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?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard