Hiding Annotation on form while record is being created, then unhiding once it's created

Winston
Tera Guru

Hey everyone, 

I have an Annotation message that pretty much just tells the user to use a related list after the record is created, but i'm trying to hide it on the form until AFTER it's created. 

Here's what I got so far:

I made an HTML Annotation and gave it the id of "additional_ci"

find_real_file.png

Here's the script:

<span id="additional_ci">Please view the "Affected CIs" related list located at 
the bottom of this form to see the full list of affected CIs.</span>

I'm trying to hide the the Annotation in an onLoad client script:

I'm using g_form.isNewRecord() to show if the form is not created yet, and this works for me in other client scripts but isn't working for me here. What am I doing wrong?

find_real_file.png

Here's the script:

function onLoad() {
	// Hide annotation if the change record is new
	if(g_form.isNewRecord()){  
		// Hide the annotation
		$('additional_ci').up().hide();
	}
	else {
		// Show the annotation
		$('additional_ci').up().show();
	}
}
1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Can you check if "Isolate script" is set to false? You might have to add the field to the Client script form.

View solution in original post

5 REPLIES 5

Willem
Giga Sage
Giga Sage

Can you check if "Isolate script" is set to false? You might have to add the field to the Client script form.

Or from the list add the column "Isolate script":

find_real_file.png

find_real_file.png

Yup, that was the issue. 

Winston
Tera Guru

I found the issue, the Isolate script field was set to true by default and wasn't showing on my form. I had to updated it from the record list, and now it works fine. 

find_real_file.png

@Ankur Bawiskar's answer on the below forum post helped me fix this. 

https://community.servicenow.com/community?id=community_question&sys_id=ba660067dbc29450f21f5583ca96...