request for help as getting error Uncaught FMessage: 'EntitySetName not specified.' while using xdatawebdataset to acces data from API as TList

Hi,

I am getting following error when I use xdatawebdataset component to get data from xdata server by xdatawebclient component. I am using database query to get customers list as follow..

XData Server side code..

//class declaration
type
  TCustomer = class
    custno: string;
    custname: string;
    address: string;
end

//interface
type
  [ServiceContract]
  [Route('customers')]
  IcustomerService = interface(IInvokable)
    ['{CCCF41C9-19AB-4DD1-AD04-166E94039879}']

    [HttpGet, Route('')]
    function GetCustomers: TList<TCustomer>;

  end;
---------------------------

// function implemented in TcustomerService class which [ServiceImplementation]
function TcustomerService.GetCustomers: TList<TCustomer>;
var
  objCustomer: TCustomer;
  i: integer;
begin
  i := 1;
  Result := TList<TCustomer>.Create;
  TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);

  objCustomer := TCustomer.Create;
  TXDataOperationContext.Current.Handler.ManagedObjects.Add(objCustomer);
  Result.Add(objCustomer);

  qryCustomer.Close;
  qryCustomer.SQL.Text := 'select custno, custname, address from customer';
  qryCustomer.Open;
  while not qryCustomer.Eof do
  begin
    objCustomer := TCustomer.Create;
    TXDataOperationContext.Current.Handler.ManagedObjects.Add(objCustomer);
    Result.Add(objCustomer);

    objCustomer.custno := qryCustomer.FieldByName('custno').AsString;
    objCustomer.custname := qryCustomer.FieldByName('custname').AsString;
    objCustomer.address1 := qryCustomer.FieldByName('address').AsString;

    qryCustomer.Next;
  end;
end;

in webcore client side, I am using following code to get data from xdata server

procedure TfrmMainPage.btnGetCustomerClick(Sender: TObject);
begin
  XDataWebClient1.RawInvoke('IcustomerService.GetCustomers', [],
  procedure(Response: TXDataClientResponse)
  begin
    XDataWebDataset1.Close;
    XDataWebDataset1.SetJsonData(TJSObject(Response.Result)['value']);
    XDataWebDataset1.Open;
  end
  );
end;

but I get following error.

db.pas:1816 Uncaught {FMessage: 'EntitySetName not specified.', FHelpContext: 0, FJSError: Error: EntitySetName not specified.
    at Object.Create$1 (http://localhost:8000/webcrm2/webcrm2.j…, FStack: 'Error: EntitySetName not specified.\n    at Object.…ttp://localhost:8000/webcrm2/webcrm2.js:51249:18)'}FHelpContext: 0FJSError: Error: EntitySetName not specified.
    at Object.Create$1 (http://localhost:8000/webcrm2/webcrm2.js:3432:23)
    at c.$create (http://localhost:8000/webcrm2/webcrm2.js:337:19)
    at Object.DatabaseError (http://localhost:8000/webcrm2/webcrm2.js:52726:31)
    at Object.CheckEntitySetName (http://localhost:8000/webcrm2/webcrm2.js:95726:46)
    at Object.InitializeFieldDefinitions (http://localhost:8000/webcrm2/webcrm2.js:95772:12)
    at Object.InternalInitFieldDefs (http://localhost:8000/webcrm2/webcrm2.js:95768:12)
    at Object.InternalOpen (http://localhost:8000/webcrm2/webcrm2.js:88417:12)
    at Object.DoInternalOpen (http://localhost:8000/webcrm2/webcrm2.js:50394:12)
    at Object.OpenCursor (http://localhost:8000/webcrm2/webcrm2.js:51216:68)
    at Object.SetActive (http://localhost:8000/webcrm2/webcrm2.js:51249:18)FMessage: "EntitySetName not specified."FStack: "Error: EntitySetName not specified.\n    at Object.Create$1 (http://localhost:8000/webcrm2/webcrm2.js:3432:23)\n    at c.$create (http://localhost:8000/webcrm2/webcrm2.js:337:19)\n    at Object.DatabaseError (http://localhost:8000/webcrm2/webcrm2.js:52726:31)\n    at Object.CheckEntitySetName (http://localhost:8000/webcrm2/webcrm2.js:95726:46)\n    at Object.InitializeFieldDefinitions (http://localhost:8000/webcrm2/webcrm2.js:95772:12)\n    at Object.InternalInitFieldDefs (http://localhost:8000/webcrm2/webcrm2.js:95768:12)\n    at Object.InternalOpen (http://localhost:8000/webcrm2/webcrm2.js:88417:12)\n    at Object.DoInternalOpen (http://localhost:8000/webcrm2/webcrm2.js:50394:12)\n    at Object.OpenCursor (http://localhost:8000/webcrm2/webcrm2.js:51216:68)\n    at Object.SetActive (http://localhost:8000/webcrm2/webcrm2.js:51249:18)"[[Prototype]]: Object
DatabaseError @ db.pas:1816
CheckEntitySetName @ XData.Web.Dataset.pas:149
InitializeFieldDefinitions @ XData.Web.Dataset.pas:197
InternalInitFieldDefs @ XData.Web.Dataset.pas:217
InternalOpen @ jsondataset.pas:1597
DoInternalOpen @ db.pas:2762
OpenCursor @ db.pas:3541
SetActive @ db.pas:3680
Open @ db.pas:4780
(anonymous) @ MainPage.pas:58
DoLoad @ XData.Web.Client.pas:357
DoLoad @ XData.Web.Client.pas:1207
OnSuccess @ XData.Web.Client.pas:1250
LocalSuccess @ XData.Web.Connection.pas:449
XhrLoad @ XData.Web.Connection.pas:180
load (async)
InternalSendRequest @ XData.Web.Connection.pas:199
SendRequest @ XData.Web.Connection.pas:479
Send @ XData.Web.Client.pas:822
Execute @ XData.Web.Client.pas:1313
InternalRawInvoke @ XData.Web.Client.pas:646
RawInvoke$2 @ XData.Web.Client.pas:785
btnGetCustomerClick @ MainPage.pas:53
cb @ rtl.js:240
Click @ WEBLib.Controls.pas:1767
HandleDoClick @ WEBLib.Controls.pas:3788
cb @ rtl.js:236

As, I checked more into this issue and I found that, if the xDataWebDataset does not have any field then this error raises. This error seems gone, after, I added fields manually to xDataWebDataset component from Fields editor option at design time.
So, is it required to must have fields added to xDataWebDataset at design time?

It is required if you don't set EntitySetName property, yes.

Thanks, Wagner

1 Like

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