Field message with GlideAjax

Viktor Stepanov
Mega Contributor

Hello all,

I need to create display field messages in an incident form.

The idea is to check whether the field in question fulfills some parameters (ie. CI = category: computer) and then show the info message under the field.
This has to be done with GlideAjax and it has to reflect the language used (ie. Spanish).

I would like to ask for a roadmap  - I'm rather new with SN and am thinking that this would be basically done with a client callable Script Include, calling the CI table via a Glide Record - then being used by a Client Script with GlideAjax?

 

Thanks,

VS

8 REPLIES 8

RAHUL Khanna1
Mega Guru

is that a ommon message or specific to CI...

 

if it is common ....you can include as g_form.showFieldMsg('field_name' , 'message');

 

Same thing can be done using glide ajax, you call the message from there store in variable and use the above syntax.

it should be a message under the field in question - reflecting the category of the ci. For example - when Configuration Item is Notebook then the message will display "Computer". When it is "Windows"  then it will display "Software" etc. And it should adapt to the language in question.

 

I just wanted to know what would be the steps in creating this. I would be able to do this with GlideRecord using Client script but obviously it is a bad approach.

Thanks!

You can definitely do this with GlideAjax and call it from a client script. Have the Script Include return the category of the CI and then write some logic for it

//Insert your GlideAjax here and return the value into a variable

var retVal = ''; //This is where you store the returned value

if(retVal == 'Category 1'){
   g_form.showFieldMsg('cmdb_ci', gs.getMessage('This is your message in english'), 'info');
}
else if(retVal == 'Category 2'){
   g_form.showFieldMsg('cmdb_ci', gs.getMessage('This is your 2nd message in english'), 'info');
}
//Keep doing this for your Categories...

 

You should use gs.getMessage() function to be able to display the value in different languages. The message will be displayed in the language chosen by the user.
The translations will be put into the Message-table (sys_ui_message), that's where you make the translations.

How do you , which language to be used to show the message....