cancel
Showing results for 
Search instead for 
Did you mean: 

CAP OData remove function - No 'Edm.Date' value found for key

lukasmetzger
Participant
0 Kudos

Hi everyone,

I am currently trying to use the OData.remove() function.

My Code looks like this:

Data Model:

entity Appointments {
    key appointDate : Date;
    key type        : String(100); 
    key employees   : Association to one Employees;
    areas           : Association to one Areas;
}

Code in the Controller:

const sPath = "/Appointments(appointDate='" + sDate + "',type='" + sCurrType + "',employees_idp_id='" + sIDP_ID +  "', employees_email=" + sEmail + "')";


oAllUserModel.remove(sPath, { 
           success: function () { }, 
           error: function (oError) {
                 MessageToast.show(oError.message); 
            }
          });

The variable sDate is formatted like this:

2021-03-15T00:00:00.000Z

But when the call is made, it fails with the error:

No 'Edm.Date' value found for key 'appointDate'

Does anyone know a solution for this Problem?

Thanks in advance!

Lukas

View Entire Topic
former_member508209
Participant
0 Kudos

Hi lukasmetzger,

In the essence, you already have the solution close to your eyes 😉 As your `appointDate` is of type `Date`, CAP (and OData) are expecting a value of 'YYYY-MM-DD' while you are sending 'YYYY-MM-DD`T`HH:MM:SS`Z`'. You can either strip of the time part using `substr(0, 10)` or change your CDS data type to `DateTime`.

Let me know if this helps!

Best,

Janik

lukasmetzger
Participant
0 Kudos

Thank you for your answer!

I just got the solution:

const sPath = "/Appointments(appointDate=" + sDate + ",type='" + sCurrType + "',employees_idp_id='" + sIDP_ID +  "', employees_email=" + sEmail + "')";

I just had ' ' around the value, which indicates a String. *facepalm*

former_member508209
Participant
0 Kudos

Good point, your right!