How to get popup (info message) on incident page

Yash38
Kilo Guru

Requirement is to include popup (info message) on create incident form in the case mobile phone number and business phone number are missing where we are asking the user depending upon the language of logged in user to maintain that contact data in the source system?

Info message to display : 

  • GER: Sind Sie interner-Mitarbeitender und wollen Ihre Kontaktdaten dauerhaft im System hinterlegen? Dann pflegen Sie diese einfach unter xyz.com (Daten zur Person --> Kontaktinformationen) ein.
  • EN: Are you an internal employee and want to permanently store your contact data in the system? Then simply enter them at xyz.com (Personal data --> Contact information).

 

On incident form we have 2 fields as mobile phone number and business phone number(Details in these fields gets auto populated from sys_user table),

we have an UI policy which makes mobile phone number field mandatory if both the above fields are empty and in that case we need to popup an info message using the scripting in the same UI Policy.

find_real_file.png

find_real_file.png

Thank You

1 ACCEPTED SOLUTION

SumanthDosapati
Mega Sage
Mega Sage

If you want to check current user language.

That is very simple. There is one shortcut for that. --> g_lang

alert(g_lang); // it will print en if english.

You can use that to add if condition. 

so your script will be :

if(g_lang == 'en')
{
g_form.addInfoMessage("Are you an internal employee and want to permanently store your contact data in the system? Then simply enter them at xyz.com Personal data --> Contact information.");
}
else if(g_lang == 'ger')
{
g_form.addInfoMessage("Sind Sie interner-Mitarbeitender und wollen Ihre Kontaktdaten dauerhaft im System hinterlegen? Dann pflegen Sie diese einfach unter xyz.com Daten zur Person --> Kontaktinformationen ein.");
}

 

Mark as correct and helpful if it solved your query.

Regards,
Sumanth

View solution in original post

19 REPLIES 19

@SUMANTH DOSAPATI,

Ok, so the logic does not require a language check in the script. All that should be required is to call the addInfoMessage() function like this:

 g_form.addInfoMessage(getMessage('are you an internal employee'));

Then have two records in the [sys_ui_message] table:

English:

Key - are you an internal employee
Language - en
Message - Are you an internal employee and want to permanently store your contact data in the system?
Then simply enter them at xyz.com (Personal data --> Contact information).

German:

Key - are you an internal employee
Language - de
Message - Sind Sie interner-Mitarbeitender und wollen Ihre Kontaktdaten dauerhaft im System hinterlegen?
Dann pflegen Sie diese einfach unter xyz.com (Daten zur Person --> Kontaktinformationen) ein.

The MessageAPI works by looking in the [sys_ui_message] table for a matching record (based on the key provided in the call) in the same language as that of the user session calling it. If there isn't a matching record for that language, it will return what was called. For example, if it was calling an English entry and there was no English record, then it would return the string passed into the MessageAPI (the same is true for any other language if the system default has been changed),

When ever there is a need to display text either in English or multiple languages by script, you should always call the MessageAPI, otherwise you are introducing significant technical debt, customizations and massive amounts of avoidable admin overhead.

Our team has also put together a complete learning path on NowLearning for the Localization topic, please check it out here,

Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

If his requirement is just to display the message based on language then yes it completely makes sense to use getMessage() 
🙂


Regards,
Sumanth

Which it is, I'm afraid your suggestion is considered as bad-practice for the reasons I stated above. So I'm afraid I will have to flag the post unless it is amended,

Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

What i thought is he will be doing something else along with showing the info message based on language. So i suggested him that.

I dont have option to edit already correct marked answer so i'll just add another comment so that future visitors will be on right track.

 

Regards,
Sumanth

@Snowy

If your requirement is just to show info message based on language then you can use getMessage() function.

You need to create two entries in sys_ui_message table for both languages and call that entry using key.

g_lang to be used only if you have other requirement along with info message based on language.

 

Regards,
Sumanth