How to hide Form Annotation until specific field condions are met

Jerri
Mega Contributor

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?

1 ACCEPTED SOLUTION

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!

View solution in original post

26 REPLIES 26

how to add marquee for that span id any idea pls 

Unfortunately, I couldn't get this to work in my Paris scoped application.

Here is the code I used.  Tried it as an onload as well.

if (g_form.getValue('request_type') == 'key request') {
// Hide the annotation
//$('checkin_annotation').up().show();
}
else {
// Show the annotation
$('checkin_annotation').up().hide();
}


find_real_file.png

 

find_real_file.png

 

 

Jerri
Mega Contributor

Thank you, this is definitely a help, but I'm still stuck because the field it needs to reference is on another table.

I'm also working in Incident. When the incident form loads, I do not want the annotation to display by default. If the user selects a Business Service/Service Offering that is flagged as Business Critical, I want the annotation to display. So, it needs to read the business criticality of the selected Service Offering from the Service Offering table, and change depending on that value.

Any additional help?

What specific business criticalities should it show for?

Jerri
Mega Contributor

There are two options

 

1 - Business Critical

2 - Non-Business Critical

 

Basically, we are just making sure the user/analyst knows they are working with a critical service offering.