ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] page 9802 "Permission Sets" - OnBeforeImportPermissionSets

Open ReneZiel opened this issue 3 years ago • 3 comments

Hello, can you please add a new Event OnBeforeImportPermissionSets in page 9802 "Permission Sets" ?

                action(ImportPermissionSets)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Import Permission Sets';
                    Enabled = CanManageUsersOnTenant;
                    Image = Import;
                    ToolTip = 'Import a file with permissions.';

                    trigger OnAction()
                    var
                        PermissionSetBuffer: Record "Permission Set Buffer";
                        TempBlob: Codeunit "Temp Blob";
                        ImportPermissionSets: XmlPort "Import Permission Sets";
#if not CLEAN21
                        ImportTenantPermissionSets: XmlPort "Import Tenant Permission Sets";
#endif
                        FileName: Text;
                        InStream: InStream;
                        OutStream: OutStream;
                        UpdateExistingPermissions: Boolean;
                        Handled: Boolean;
                    begin
                        UploadIntoStream('Import', '', '', FileName, InStream);
                        TempBlob.CreateOutStream(OutStream);
                        CopyStream(OutStream, InStream);

                        TempBlob.CreateInStream(InStream);
                        OnBeforeImportPermissionSets(TempBlob, UpdateExistingPermissions, Handled);
                        if not Handled then
                             UpdateExistingPermissions := Confirm(UpdateExistingPermissionsLbl, true);
#if not CLEAN21
                        if IsImportNewVersion(InStream) then begin
                            ImportPermissionSets.SetSource(InStream);
                            ImportPermissionSets.SetUpdatePermissions(UpdateExistingPermissions);
                            ImportPermissionSets.Import();
                        end else begin
                            ImportTenantPermissionSets.SetSource(InStream);
                            ImportTenantPermissionSets.SetUpdatePermissions(UpdateExistingPermissions);
                            ImportTenantPermissionSets.Import();
                        end;
#else
                            ImportPermissionSets.SetSource(InStream);
                            ImportPermissionSets.SetUpdatePermissions(UpdateExistingPermissions);
                            ImportPermissionSets.Import();
#endif

                        PermissionSetBuffer := Rec;
                        Rec.FillRecordBuffer();
                        if Rec.Get(PermissionSetBuffer.Type, PermissionSetBuffer."Role ID") then;
                    end;
                }
    [IntegrationEvent(false, false)]
    local procedure OnBeforeImportPermissionSets(TempBlob: Codeunit "Temp Blob"; var UpdateExistingPermissions: Boolean; var Handled: Boolean)
    begin
    end;

ReneZiel avatar Jul 19 '23 11:07 ReneZiel

Hi @ReneZiel, what's the scenario behind wanting this event?

darjoo avatar Jul 24 '23 07:07 darjoo

We would like to check the Permission Import File before.

ReneZiel avatar Jul 31 '23 07:07 ReneZiel

After further discussion with the team, we've decided not to proceed with the email. It looks like a very specific case where using the event would allow you to skip the Confirm dialog.

The suggestion is to extend the page and add your own action that does that.

darjoo avatar Aug 07 '23 13:08 darjoo