Anveo Mobile App / Base App Features / Dynamic Tile Captions in Main Menu

Dynamic Tile Captions in Main Menu

The dynamic change of tile captions in the main menu is performed within the OnOpenMenu Trigger of the corresponding main menu. This way the icon, color and text of the tile can be adjusted.

Icons/Colors

The icon and color of the main menu tiles are stored in the table ACF Anveo Page Element Menu. In order to change these values on the app, the corresponding entry in the table must first be identified. All menu entries that do not belong to an Anveo Page are marked by the field Anveo Page Code being empty.

local anveoPageElementMenu = Record('ACF Anveo Page Element Menu');

-- [[get Main Menu Entry for My Messages]]
anveoPageElementMenu:SETRANGE('Anveo Page Code','');
anveoPageElementMenu:SETRANGE('Action Code','');
anveoPageElementMenu:SETRANGE('Linked Anveo Page','ASLS_NOTIFICATIONS');
anveoPageElementMenu:FINDFIRST();

In this entry, the symbol and background color can be changed dynamically by changing the Background Color and Icon Description fields. A complete example of the notifications could look like this:

local anveoPageElementMenu = Record('ACF Anveo Page Element Menu');
local ACFNotification = Record('ACF Notification');
local colorRed = '#bd3939';
local colorGreen = '#00b050';
local colorBlue = '#5b9bd5';
local colorGray = '#7c7c7c';

-- [[get Main Menu Entry for My Messages]]
anveoPageElementMenu:SETRANGE('Anveo Page Code','');
anveoPageElementMenu:SETRANGE('Action Code','');
anveoPageElementMenu:SETRANGE('Linked Anveo Page','ASLS_NOTIFICATIONS');
anveoPageElementMenu:FINDFIRST();
--[[check if there are unread Notifications]]
ACFNotification:SETRANGE('Status', 5);
if ACFNotification:ISEMPTY() then
--[[no unread messages]]
--[[set the background color to gray and set the symbol to "mail"]]
anveoPageElementMenu:SETVALUE('Background Color', colorGray);
anveoPageElementMenu:SETVALUE('Icon Description', 'mail');
anveoPageElementMenu:MODIFY(false);
else
--[[there are unread messages]]
--[[set the background color to red and set the symbol to "mail_open"]]
anveoPageElementMenu:SETVALUE('Background Color', colorRed);
anveoPageElementMenu:SETVALUE('Icon Description', 'mail_open');
anveoPageElementMenu:MODIFY(false);
end;

Text

The texts for main menu entries are defined in the table ACF Multilanguage. They are identified by table number, PK fields and language. The Value field contains the text that is displayed. For the table ACF Anveo Page Element Menu (in which the main menu tiles are stored) these can be found and changed as follows:

local anveoPageElementMenu = Record('ACF Anveo Page Element Menu');
anveoPageElementMenu:SETRANGE('Anveo Page Code','');
anveoPageElementMenu:SETRANGE('Action Code','');
anveoPageElementMenu:SETRANGE('Linked Anveo Page','ASLS_NOTIFICATIONS');
anveoPageElementMenu:FINDFIRST();

--[[Get Multilanguage Entry for currently selected Language and Main Menu entry]]
local multilanguage = Record('ACF Multilanguage');
multilanguage:SETRANGE('PK Table No.', anveoPageElementMenu:GETTABLENO());
multilanguage:SETRANGE('Language', GLOBALLANGUAGECODE());
multilanguage:SETRANGE('PK No. 1', anveoPageElementMenu:GETVALUE('Anveo Page Element Line No.'));
multilanguage:SETRANGE('PK No. 2', anveoPageElementMenu:GETVALUE('Entry No.'));
multilanguage:FINDFIRST();
multilanguage:SETVALUE('Value','Hello World');
multilanguage:MODIFY(false);

Example for changing the Notification Tile of the Anveo Base Apps

The example for the notifications then looks as follows, including changing the texts:

local function changeText(anveoPageElementMenu,text)
--[[Get Multilanguage Entry for currently selected Language and Main Menu entry]]
local multilanguage = Record('ACF Multilanguage');
multilanguage:SETRANGE('PK Table No.', anveoPageElementMenu:GETTABLENO());
multilanguage:SETRANGE('Language', GLOBALLANGUAGECODE());
multilanguage:SETRANGE('PK No. 1', anveoPageElementMenu:GETVALUE('Anveo Page Element Line No.'));
multilanguage:SETRANGE('PK No. 2', anveoPageElementMenu:GETVALUE('Entry No.'));
multilanguage:FINDFIRST();
multilanguage:SETVALUE('Value',text);
multilanguage:MODIFY(false);
end;

local anveoPageElementMenu = Record('ACF Anveo Page Element Menu');
local ACFNotification = Record('ACF Notification');
local colorRed = '#bd3939';
local colorGreen = '#00b050';
local colorBlue = '#5b9bd5';
local colorGray = '#7c7c7c';

-- [[get Main Menu Entry for My Messages]]
anveoPageElementMenu:SETRANGE('Anveo Page Code','');
anveoPageElementMenu:SETRANGE('Action Code','');
anveoPageElementMenu:SETRANGE('Linked Anveo Page','ASLS_NOTIFICATIONS');
anveoPageElementMenu:FINDFIRST();
--[[check if there are unread Notifications]]
local total = ACFNotification:COUNT();
ACFNotification:SETRANGE('Status', 5);
local unread = ACFNotification:COUNT();
if ACFNotification:ISEMPTY() then
--[[no unread messages]]
--[[set the background color to gray and set the symbol to "mail"]]
anveoPageElementMenu:SETVALUE('Background Color', colorGray);
anveoPageElementMenu:SETVALUE('Icon Description', 'mail');
anveoPageElementMenu:MODIFY(false);
--[[change Text accordingly]]
changeText(anveoPageElementMenu,GETTEXT('ASLS_NOTIFICATIONS',total));
else
--[[there are unread messages]]
--[[set the background color to red and set the symbol to "mail_open"]]
anveoPageElementMenu:SETVALUE('Background Color', colorRed);
anveoPageElementMenu:SETVALUE('Icon Description', 'mail_open');
anveoPageElementMenu:MODIFY(false);
--[[change Text accordingly]]
changeText(anveoPageElementMenu,GETTEXT('ASLS_NOTIFICATIONS_UNREAD',total,unread));
end;