table 50000 "General Setup"
{
DataClassification = CustomerContent;
Caption = 'General Setup';
Access = Internal;
fields
{
field(50000; "Primary Key"; Code[10])
{
DataClassification = CustomerContent;
Caption = 'Primary Key';
}
}
keys
{
key(PK; "Primary Key")
{
Clustered = true;
}
}
procedure SetPassword(NewPassword: Text)
var
EncryptionManagement: Codeunit "Cryptography Management";
begin
//Delete old password if exist
if IsolatedStorage.Contains(GetStorageKey(), DataScope::Module) then
IsolatedStorage.Delete((GetStorageKey(), DataScope::Module));
//Encrypt password if possible
if EncryptionManagement.IsEncryptionEnabled() and EncryptionManagement.IsEncryptionPossible() then
NewPassword := EncryptionManagement.Encrypt(NewPassword);
//Set new password by storage key
IsolatedStorage.set(GetStorageKey(), NewPassword, DataScope::Module);
end;
procedure GetPassword(): Text
var
EncryptionManagement: Codeunit "Cryptography Management";
PasswordTxt: Text;
begin
//Check if password exist by storage key
if IsolatedStorage.Contains(GetStorageKey(), DataScope::Module) then begin
//Get exist password
IsolatedStorage.Get(GetStorageKey(), DataScope::Module, PasswordTxt);
//Decrypt password if possible
if EncryptionManagement.IsEncryptionEnabled() and EncryptionManagement.IsEncryptionPossible() then
PasswordTxt := EncryptionManagement.Decrypt(PasswordTxt);
//Return password
exit(PasswordTxt);
end;
end;
local procedure GetStorageKey(): Text
var
StorageKeyTxt: Label '25edcb48-11b9-4e7d-8645-2c95b3156092', Locked = true;
begin
exit(StorageKeyTxt);
end;
}
page 50000 "General Setup"
{
PageType = Card;
ApplicationArea = All;
UsageCategory = Administration;
SourceTable = "General Setup";
Caption = 'General Setup';
layout
{
area(Content)
{
group(General)
{
field(PasswordTxt; PasswordTxt)
{
ApplicationArea = All;
ExtendedDatatype = Masked;
Caption = 'Password';
trigger OnValidate()
begin
SetPassword(PasswordTxt);
Commit();
end;
}
}
}
}
trigger OnOpenPage()
begin
Reset();
if not Get() then begin
Init();
Insert();
SetPassword('');
end else
PasswordTxt := '***';
end;
var
PasswordTxt: Text;
}