TWebClientDataSet.GetPendingUpdates

I did not find documentation and no sample, so I would appreciate some assistance.

For testing purposes I created a simple form, added a TWebClientDataSet and inserted some records. In the real app, data comes from a REST service , gets edited and should be written back. So I need access to the changes.

This is what I tried:

procedure TForm2.btnInsertClick(Sender: TObject);
var
  n: Integer;
begin
  n := cdsData.RecordCount + 1;
  cdsData.InsertRecord([n, 'zeile1']);
end;

procedure TForm2.btnGetUpdatesClick(Sender: TObject);
var
  i: Integer;
  resArray: TResolveinfoArray;
  s: string;
  Info: PTypeInfo;
begin
  Info := System.TypeInfo(TUpdateStatus);
  resArray := cdsData.GetPendingUpdates;
  for i := 0 to High(resArray) - 1 do  begin
    s:='';
    s:=s+'Status '+GetEnumName(Info,ord(resArray[i].Status));
  // log all data here
   ShowMessage(s);
  end;
end;

However, PendingUpdates is nil. Looking at the source:

function TWebCustomClientDataSet.GetPendingUpdates: TResolveInfoArray;
begin
  Result := nil;
end;

So, I think I am missing something basically here.

BTW: TJSValue - how do I access these values or how to comvert this?

Thanks a lot!
Bernd

I suspect you look at the design-time code.

The runtime GetPendingUpdates is in Core Source\RTL\DB.pas defined for base class TDataSet and it is not returning nil but a TResolveInfoArray.

Ups. My fault.
Still my question is: Why is the TResolveInfoArry nil in this case and how do I get access to the changes?

To be precise, ResolveInfoArry is not nil, the GetpendingUpdates throws an error

 ERROR
TypeError: this.FChangeList is null | this.GetRecordUpdates@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:77919:38 this.GetPendingUpdates@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:79409:67 this.btnUpdatesClick@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:108219:31 cb@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:245:19 this.Click@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:29776:61 this.HandleDoClick@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:29265:31 cb@http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js:241:26
at http://localhost:8000/projGetPendingUpdates/projGetPendingUpdates.js [77919:38]

I cannot reproduce a problem.
Test applied on demo Demo\Basics\Dataset with code:

procedure TForm1.WebButton2Click(Sender: TObject);
var
  ar: TResolveInfoArray;
  i: integer;
begin
  ar := webclientdataset1.GetPendingUpdates;
  for I := 0 to length(ar) - 1 do
  begin
    console.log(ar[i]);
  end;
end;

shows after 2 edits in the console:

For me this does not even compile, because the concole.log needs a TJSValue, so this compiles for me:
console.log(resArray[i].Data);

However I have attached my demo, maybe this helps you to point out what I am missing.

Thank you very much, Bruno!
projGetPendingUpdates.zip (7.8 KB)

Issue is caused by this dataset having no client connection, hence no dataproxy.
We'll check this with the pas2js team as this is in the DB RTL. Meanwhile, we implemented a workaround that will be in the next beta.

I see. Thank´s for verifying.