How to add an info message to a field selection

msmo
Kilo Guru

I need help creating a Catalog Client Script to show an info message when a variable is set to yes.

 

*will contractor require a laptop? If yes, I'd like to show an info, warning or error message, under the field to show a msg "You must attach an approval email from the director of talent acquisition".

value - ctr_requires_laptop

Any help you could be provide would be greatly appreciated.

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

You can do this with an onChange Catalog Client Script when this variable changes.  The script would look something like this:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	
    if (newValue == 'yes') { //replace with your variable Value
        g_form.showFieldMsg("ctr_requires_laptop", "You must attach an approval email from the director of talent acquisition.", "error");
    } else {	
        g_form.hideFieldMsg("ctr_requires_laptop");
    }
}

https://docs.servicenow.com/bundle/xanadu-api-reference/page/script/useful-scripts/reference/r_Displ... 

 

It sounds like you will also want to make an attachment type variable mandatory at this time, or if you are not using a variable for this you can have an onSubmit Catalog Client Script that checks the attachment table for a record from this request and prohibits the submission if one is not present.

Thank you so Much Brad!