Hi,
I have added an event when creating a xdata module, according to the doc:
FoModule.Events.OnManagerCreate.Subscribe(
procedure(Args: TManagerCreateArgs)
var
lnOrgId : int64;
begin
if (Args.Handler.Request.User <> nil) and (args.Handler.Request.User.Claims.Exists('OrgId') )then begin
lnOrgId := Args.Handler.Request.User.Claims.Items['OrgId'].AsInt64;
Args.Manager.EnableFilter('Org').SetParam('OrgId', lnOrgId);
end;
end
);
In the service implementation, I have
...
Result := TXDataOperationContext.Current.GetManager.FindAll<TAccount>;
...
TAccount being a filtered entity with the Org filter
When used this way the records are not filtered.
if I put the filter into the service implementation function, ie
...
if TXDataOperationContext.Current.Request.User <> nil then begin
TXDataOperationContext.Current.Request.User.Claims.Items['OrgId'].AsInt64;
TXDataOperationContext.Current.GetManager.EnableFilter('Org').SetParam('OrgId', lnOrgid);
end;
Result := TXDataOperationContext.Current.GetManager.FindAll<TAccount>;
...
then it works.
Does TXdataOperationContext reference the manager available through args in the event ?