Catalog Item Annotation HTML Variable Instructions on form
This content was last updated in 2020. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 06:25 PM
I'm using the CMS and wanted to annotate my catalog item form with some instructions without using the help text facility. I know you can create a UI Macro but it seems a waste to have to create and link a new ui macro for each annotation on every item.
I also am going to service portal soon too and I read you can use the widget selector under the "default value" tab on the macro variable to display a widget on the service portal and you can pass a value to the widget through the default value field. This got me thinking.
Then I read this post https://community.servicenow.com/thread/226154 about the instructions field on a variable and how it is shown in service portal. "Brilliant" I thought - thats exactly what I need but for the CMS. (I always wondered what that field did).
So I built a UI Macro, which gets the html from the instructions field on the variable. This way you only have to have 1 UI Macro to display an annotation. You also get a WYSWIG HTML Editor and as an added bonus its future compatible with service portal! (Because UI Macros dont show in SP, but the instructions field does).
Heres the UI macro:
Name: variable_html
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate jelly="true">
var gr = new GlideRecord('item_option_new');
gr.get(jelly.jvar_question_id);
gr
</g:evaluate>
<div class="help-block text-muted col-xs-6">
<g:no_escape>${gr.instructions}</g:no_escape>
</div>
</j:jelly>
Heres a screencap of the UI macro.
Here a screencap of the UI Macro Variable on a catalog Item and where to put the HTML for your annotation.
This is where to specify the new "variable_html" UI Macro on the catalog item variable.
And this is what it looks like on the CMS
And this is what it looks like on the service portal.
- 26,266 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2018 03:23 AM
Hello experts,
This work well.
But here we are 11 different languages and user to see this help text according to their language preference, Is there a way to achieve that?
Any help will be appreciated.
Thanks
Neeraj Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2018 06:28 PM
I am not 100% sure. But I would start here:
https://docs.servicenow.com/bundle/jakarta-platform-administration/page/administer/localization/concept/c_UseTranslatedText.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2018 11:48 PM
Hello Hadyn,
I have read those documents and found that gs.getMessage('Text') is a function which can be used to translate text in servicenow but i am not to make it work in UI Macro script.!
Thats how i am trying to do..
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate jelly="true">
var gr = new GlideRecord('item_option_new');
gr.get(jelly.jvar_question_id);
gr
</g:evaluate>
<div class="help-block text-muted col-xs-6">
<g:no_escape>${gs.getMessage(gr.instructions)}</g:no_escape>
</div>
</j:jelly>
Please bear with me i am only 2 days old in Jelly..
Thanks
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2018 05:37 PM
Your code looks good to me. If it is not returning anything then I think your problem lies elsewhere. I would test getting the value in a background script first until its proven to work then move on to the UI macro.
var gr = new GlideRecord('item_option_new');
if(gr.get('put_a_sys_id_here')){
gs.addInfoMessage('got the record');
gs.addInfoMessage('Without GetMessage: ' + gr.instructions);
gs.addInfoMessage('With GetMessage: ' + gs.getMessage(gr.instructions));
} else {
gs.addErrorMessage('Couldnt find that record');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2018 01:47 PM
Hi Hadyn,
We have been using this macro to display help text, but it appears that it no longer works in London. Have you experienced the same?
Thanks,
Chris