cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bahalzamon
Advocate II
Advocate II

DateTime CDS Patch

I am attempting to use Patch to update a record within CDS. I just want to update a Date/Time field.

Here is what I have tried and some info:

  • column is a date/time field
  • record exists
  • edited other non date/time data in the record
  • i am the only one working on it
  • have attempted using just Now()
  • using today and adding time to it
  • saving the date/time to a variable then passing that in
  • changing the timezone format to UTC
  • using UpdateIf
  • ensuring I can pull information using my DataTable.Selected
  • using a lookup rather than DataTable.Selected

 

Patch(
    MyPerson,
    DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

 

I am sure there are many more that I have tried, but this is driving me nuts lol
Any help is definitely appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Bahalzamon
Advocate II
Advocate II

@CNT  Just attempted and nothing, I am really unsure why.

@mdevaney Thanks for the reply but I had mentioned I attempted that but I did just attempt again just to be sure I typed it in correctly and no go.

 

I did get it resolved using an UpdateIf, I am unsure why the Patch would not work. Here is my final code that is working.

UpdateIf(
    MyPerson,
    Person=DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

I am usually hesitant using UpdateIf as it can change multiple records, but as I'm calling the GUID I am safe-ish lol. =P

View solution in original post

5 REPLIES 5
CNT
Super User
Super User

@Bahalzamon What exactly is the problem?

My apologies, nothing happens, no data saved, nothing edited.

I used Errors() as well and nothing

@Bahalzamon I tried and it seems to work. Just to check it on your side, do the following and check if updates the first record.

 

Patch(
    MyPerson,
    First(MyPerson),
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

mdevaney
Super User
Super User

@Bahalzamon 

I believe the 2nd argument is your problem.  Try this instead.

Patch(
    MyPerson,
    LookUp(MyPerson, Person=DataTable.Selected.Person),
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Bahalzamon
Advocate II
Advocate II

@CNT  Just attempted and nothing, I am really unsure why.

@mdevaney Thanks for the reply but I had mentioned I attempted that but I did just attempt again just to be sure I typed it in correctly and no go.

 

I did get it resolved using an UpdateIf, I am unsure why the Patch would not work. Here is my final code that is working.

UpdateIf(
    MyPerson,
    Person=DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

I am usually hesitant using UpdateIf as it can change multiple records, but as I'm calling the GUID I am safe-ish lol. =P

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,529)