SampleAnonymizeDialog
in the BlueprintāSample-section of B1.UiInteractionService
A user can anonymize fields in a BE using Akioma.Swat.UiInteraction.UiInteractionService.
It implements the Akioma.Swat.UiInteraction.IUiInteractionService interface, so a custom implementation could also be provided.
The UI service can be included in a BE by declaring a new variable and instantiating it:
DEF VAR oUiInteractionService AS Akioma.Swat.UiInteraction.UiInteractionService NO-UNDO.
oUiInteractionService = NEW Akioma.Swat.UiInteraction.UiInteractionService().
It can also be included as a property:
DEFINE PROTECTED PROPERTY UiInteractionService AS Akioma.Swat.UiInteraction.IUiInteractionService NO-UNDO
GET:
RETURN {Consultingwerk/get-service.i Akioma.Swat.UiInteraction.IUiInteractionService "NEW Akioma.Swat.UiInteraction.UiInteractionService()"}.
END GET.
Once this is instantiated, it can be used for a buffer. For each record, we must do an InitializeBuffer and FinalizeBuffer.
METHOD OVERRIDE PROTECTED VOID ReceiveData():
FOR EACH eEntity:
oUiInteractionService:InitializeBuffer(BUFFER eEntity:HANDLE).
oUiInteractionService:AnonymizeFields(BUFFER eEntity:HANDLE, "SelfDesc").
oUiInteractionService:FinalizeBuffer(BUFFER eUeEntityser:HANDLE).
END.
END METHOD.
If we donāt do InitializeBuffer
, an error will be thrown.
If we donāt do FinalizeBuffer
, the uiAttributes from the previous record will be copied.
In the above usecase, we anonymize the āSelfDescā field in our eEntity records. Different checks can be performed here, based on security tokens or other restrictions.
The implementation of the anonymization is done in the UIControl. See below for more details.
UIControl
Alternatively, you can anonymize fields without using the UiInteractionService (UiInteractionService makes use of UIControl under the hood).
This can be done like below, using the UIControl directly.
METHOD OVERRIDE PROTECTED VOID ReceiveData():
FOR EACH eEntity:
oUiControl = NEW Akioma.Swat.UiInteraction.UiControl().
oUiControl:AnonymizeBufferFields(BUFFER eEntity:HANDLE, eEntity.SelfHdl , "!SelfKey,!SelfHdl,!SelfDesc,*").
ASSIGN eEntity.akUiActions = oUiControl:Serialize().
END.
END METHOD.
AnonymizeBufferFields takes as parameters:
- buffer field handle
- the identifier field, usually selfHdl
- a CAN-DO pattern list to determine which fields will be anonymized;
It is a list of field names to be anonymized, separated by commas.
In this list, you can use wildcard characters to represent multiple fields. For example, '*' will match all fields, and '!SelfKey' will match all fields except SelfKey. This method may be useful in cases where you need to perform additional checks or special handling for certain fields.
SampleAnonymizeDialog
in Swat provides a good example of how to use this functionality in a real-world scenario. This uses as a base, the user grid and anonymizes the āSelfDescā field.Back to Documentation
Back to Home Page