I cant figure out what this means **Id not set on Entity**

Sorry for so many posts

As I have been adding fields to the database, I have been hand tweaking the Entities definition on the server.

This has me puzzled. I have compared to the last update on my GIT repo. I cant see where I have gone wrong. Is it a Database issue or I have stuffed something up?

Even swagger gives me an error. This is when I do a get (for all records). Getting one record works fine.

{
"error": {
"code": "IdNotSetException",
"message": "Id not set on entity of class TStaff."
}
}

Expanded error from the app when fetching records to display on grid

{FMessage: 'XData server request error.\nUri: https://example…etException
Id not set on entity of class TStaff.', FHelpContext: 0, FJSError: Error: XData server request error.
Uri: https://example.com.au:2003/chopper/Staff?$top=10&$inl…, FStack: 'Error: XData server request error.
Uri: https://fl…rLoad (http://localhost:8000/ops/ops.js:56477:34)', FErrorResult: {…}}
FErrorResult
:
{FResponse: {…}, FRequestId: 'list', FErrorCode: 'IdNotSetException', FErrorMessage: 'Id not set on entity of class TStaff.', FRequestUrl: 'https://example.com.au:2003/chopper/Staff?$top=10&$inlinecount=allpages', …}
FHelpContext
:
0
FJSError
:
Error: XData server request error. Uri: https://example.com.au:2003/chopper/Staff?$top=10&$inlinecount=allpages Status code: 500 Error Code: IdNotSetException Id not set on entity of class TStaff. at Object.Create$1 (http://localhost:8000/ops/ops.js:3493:23) at Object.Create$2 (http://localhost:8000/ops/ops.js:57450:39) at c.$create (http://localhost:8000/ops/ops.js:359:19) at Object.DoError (http://localhost:8000/ops/ops.js:56855:57) at LocalSuccess (http://localhost:8000/ops/ops.js:57002:22) at LocalSuccess (http://localhost:8000/ops/ops.js:56332:23) at XMLHttpRequest.XhrLoad (http://localhost:8000/ops/ops.js:56477:34)
FMessage
:
"XData server request error.
Uri: https://example.com.au:2003/chopper/Staff?$top=10&$inlinecount=allpages\nStatus code: 500
Error Code: IdNotSetExceptio
nId not set on entity of class TStaff."
FStack
:
"Error: XData server request error.\nUri: https://example.com.au:2003/chopper/Staff?$top=10&$inlinecount=allpages
Status code: 500
Error Code: IdNotSetException
Id not set on entity of class TStaff.\n at Object.Create$1 (http://localhost:8000/ops/ops.js:3493:23)\n at Object.Create$2 (http://localhost:8000/ops/ops.js:57450:39)\n at c.$create (http://localhost:8000/ops/ops.js:359:19)\n at Object.DoError (http://localhost:8000/ops/ops.js:56855:57)\n at LocalSuccess (http://localhost:8000/ops/ops.js:57002:22)\n at LocalSuccess (http://localhost:8000/ops/ops.js:56332:23)\n at XMLHttpRequest.XhrLoad (http://localhost:8000/ops/ops.js:56477:34)"
[[Prototype]]
:
Object

I have attached my Entities file. I would be grateful for any pointers.

Srv_Entities.pas (54.2 KB)

Hi @Rohit_Nz, possible reason is an id with value 0. A quick search of the error in our Support Center brings several topics:

I had thought of two possible reasons

  1. Id of 0, which I have always had for a reserved record.
  2. Field called Id

What I had done

  1. Emptied the table, but the problem persisted
  2. Recreated the table, the problem disappeared
  3. Added a record with Id 0 and the problem was back - Annoying to break a habit of lifetime. The databases are fine with, so are MyPHPAdmin and Mysql Workbench. :-)
  4. Anyway, changed it to -1. It works, so that will do me.
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.