- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 02:12 AM
Hi,
Actually I need to show/hide options on one field based on another field.
I can achieve this using g_form.clearOptions() , addOption() & removeOption(). But, its actually removing or adding options.
Is there any other way available to show or hide options other than the above specified. ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 02:50 AM
Hi Prabhu,
you should create entry into UI messages table for those drop down values and adding option should be possible using getMessage()
refer below links for help
translations for onChange catalog client script through getmessage() method not working
Coding Help for retrieving the value from sys_message table
How to use gs.getMessage() to get the string translated?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 02:27 AM
Hi,
Unlike other fields such as reference where you can apply filter and hide value
Nothing is present for Choice
Only way is to show/hide using addOption() and removeOption()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 02:46 AM
Hi Ankur,
Thanks for the reply.
What issue I am actually facing is, I am using spanish translations for options and if the client script (add/remove options) gets executed, then it translated texts will be removed.
Whether can I make use of getMessage() inside addOption() to preserve the translations part ?
With Regards,
Prabhu V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 02:50 AM
Hi Prabhu,
you should create entry into UI messages table for those drop down values and adding option should be possible using getMessage()
refer below links for help
translations for onChange catalog client script through getmessage() method not working
Coding Help for retrieving the value from sys_message table
How to use gs.getMessage() to get the string translated?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 03:33 AM
Hi Ankur,
I have modified my client script like the above shared links.
if(selectedValue == 'Demo'){
getMessage('Option1', function(msg){
g_form.addOption('relationship_with_employee','Option1',msg);
});
getMessage('Option2', function(msg1){
g_form.addOption('relationship_with_employee','Option2',msg1);
});
getMessage('Option3', function(msg2){
g_form.addOption('relationship_with_employee','Option3',msg2);
});
}
And I have created records in the Messages table also.
Here, What issue I am facing is I am getting translated value of only Option1. Option2 and Option3 remains untranslated.
Whether you got any suggestions ?
With Regards,
Prabhu V