- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2018 10:55 AM
I am trying to add a form annotation that displays only if certain field conditions are met. Can anyone point me in the right direction?
Solved! Go to Solution.
- Labels:
-
User Experience and Design

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2018 12:32 PM
Change your client script to run 'onChange' against the 'Business service' field. Then use the script below (adjusting the Business Criticality values to match yours as needed) and you should be good to go.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// Get the 'Business service' reference
var bs = new GlideRecord('cmdb_ci_service');
bs.addQuery('sys_id', newValue);
bs.query(showBSAnnotation);
}
function showBSAnnotation(bs) {
if (bs.next()) {
// Show annotation if high business criticality.
if ((bs.busines_criticality == '1 - most critical') || (bs.busines_criticality == '2 - somewhat critical')) {
// Hide the annotation
$('my_annotation').up().show();
}
else {
// Hide the annotation
$('my_annotation').up().hide();
}
}
else {
// Hide the annotation
$('my_annotation').up().hide();
}
}
Please mark this response correct if I've answered your question. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2018 12:19 PM
And are these the actual values of those choices or just the labels? Can you right-click the 'Business criticality' field label on the Business Service table and select 'Show choice list' to confirm? We need the actual values, not the labels.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2018 12:32 PM
Change your client script to run 'onChange' against the 'Business service' field. Then use the script below (adjusting the Business Criticality values to match yours as needed) and you should be good to go.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// Get the 'Business service' reference
var bs = new GlideRecord('cmdb_ci_service');
bs.addQuery('sys_id', newValue);
bs.query(showBSAnnotation);
}
function showBSAnnotation(bs) {
if (bs.next()) {
// Show annotation if high business criticality.
if ((bs.busines_criticality == '1 - most critical') || (bs.busines_criticality == '2 - somewhat critical')) {
// Hide the annotation
$('my_annotation').up().show();
}
else {
// Hide the annotation
$('my_annotation').up().hide();
}
}
else {
// Hide the annotation
$('my_annotation').up().hide();
}
}
Please mark this response correct if I've answered your question. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 04:44 AM
Hi Mark,
Thanks for this script and posts, this is what I was looking to for, however I cannot get it to work.... help
I want the annotation to appear if Assignment group is null. With the Isolated script unchecked, the annotation stays on the screen regardless of the value in assignment group, with the Isolated Script is checked, I get the following message.
What am I doing wrong?
Here is my script
if (g_form.getValue('assignment_group') == null ) {
// Hide the annotation
$('my_annotation').up().hide();
}
else {
// Show the annotation
$('my_annotation').up().show();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2019 01:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2020 01:18 PM
Hi there,
Is it possible to amend this script to control the display of multiple annotations, rather than having to write separate scripts for each annotation?
Thanks
Steph