XData.Web.Dataset : TUpdateStatus Problem

I have a handler set for the TXDataWebDataset.AfterApplyUpdates event:


procedure TBaseEditForm.AfterApplyUpdates(Sender: TDataset; Info: TResolveResults);
var
  lRecords: Integer;
  lStatus: TUpdateStatus;
begin
  lRecords := Length(Info.Records);
  if lRecords > 0 then
  begin
    lStatus := Info.Records[0].Status;
    case lStatus of
      TUpdateStatus.Unmodified:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'far fa-check-square');
      TUpdateStatus.Modified:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'fas fa-check-circle');
      TUpdateStatus.Inserted:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'fas fa-check-circle');
      TUpdateStatus.Deleted:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'far fa-trash-alt');
      TUpdateStatus.Resolved:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'fas fa-check-circle');
      TUpdateStatus.ResolveFailed:
        ShowAnAwesomeToast(SaveTitle(lStatus), SaveDescription(lStatus), 'far fa-exclamation-triangle');
    end;
  end;
end;

I created the list using auto completion and it provided me with all the enumerations as expected (and shown above).

However when I compile I get the error

identifier not found "Unmodified"

I have XData.Web.Dataset in the Interface Uses clause and have also added XData.Web.JsonDataset but to no avail.

Any ideas?

Thanks.

One strange thing is that in another form it is recognised. Ctrl-Right-Click on TUpdateStatus takes me to the same place

XData.Web.Dataset : TUpdateStatus = XData.Web.JsonDataset.TUpdateStatus;

Looking at this solved the problem

These are recognised when building:

    TUpdateStatus.usModified
    TUpdateStatus.usInserted
    TUpdateStatus.usDeleted

And these are not:

   TUpdateStatus.usUnmodified
   TUpdateStatus.usResolved
   TUpdateStatus.usResolveFailed

So a difference between the debug code and the main code?

Why do you imply something is related to "debug code", if you haven't mentioned anything related to it before?

You mentioned that it works in a form but not in another form, so my first guess is that it migh be related to the order of units in your uses clause. Can you check if that's the case?

Sorry I left it too late to edit original post and perhaps didn't explain myself well enough in the second. I'd spent so long tracing down where the problem is in WebCore TWebSentry that I was probably a bit tired.

I shouldn't have said debug code, rather code used for compiling to a JS application and code referenced in the IDE.

In \XData\source\core\XData.Web.JsonDataset.pas TUpdateStatus is defined as:

TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted, usResolved, usResolveFailed);

However when the WebCore app is compiled only usModified, usInserted, usDeleted are recognised and the other three values raise the error of unrecognised.

The 3 recognised values are the ones defined in C:\DC\TMS\WEBCore\Core Source\RTL\Db.pas

TUpdateStatus = (usModified, usInserted, usDeleted);

So perhaps this is the problem. I tried putting DB after the others in the Uses clause but as C:\DC\TMS\XData\source\core\web\XData.Web.JsonDataset.pas (which I think is what is used for compiling - although not sure) doesn't contain the TUpdateStatus definition then that wouldn't matter.

I hope this explains the matter more clearly. For the moment the 3 available values are sufficient for the app I'm building.

Ah, ok. Yes, indeed that's the culprit. The extra enumerated values in TUpdateStatus are only visible in the "IDE code", and should not be there. We have fixed this internally and they won't be present in next version.

Great, prevent some confusion (at least for me).

One question, what if ApplyUpdates doesn't apply all the updates because of a record versioning conflict etc?

You can use the event AfterApplyUpdates which provides you with a list of the records updated and each of them has error information, if it exists.

Here is an example of use of AfterApplyUpdates (for a different purpose): TxDataWebDataset / ID AutoInc - #3 by wlandgraf

Besides the “Bookmark” property displayed in the example, there are others, Error is one of them.