Change text if no results found

Brian Sorensen
Giga Guru

I have a very simple check record form that our HR team uses.

It has the following

1. Position ID to Check - text.  They can enter what they want

2. Available asset - Reference to the ALM table.  We look at the Position ID, and it returns what device is assigned, if available.

 

BrianSorensen_0-1702573755945.png

The question I have been asked to review

If there is No Matches Found, can I change that Text to read something like - Please contact IT ?

2 REPLIES 2

Brian Sorensen
Giga Guru

Nevermind...
Found this 
https://www.servicenow.com/community/itsm-forum/how-to-change-no-matches-found-message-for-a-referen...


and it notes that it could break a lot of things if you change it. 

Stefan Georgiev
Tera Guru

Hello @Brian Sorensen ,

a bit complicated solution is possible. It involves a client script, script include and additional variable/field message

 

  1. Create an on change client script on the Position ID to Check, every time the field changes it is going to call a the script include with GlideAjax.

  2. Create a rich text variable that contains the text you want (Please contact IT ), you can make it bold, read or something else, put it under the Asset variable and make it hidden.
  3. Create the script include, it is going to contain one function that is going to check the Asset table with the reference qualifier that you are going to build and if it finds record it is going to return true, if no false
  4. The client script receives the response from the script include with a callback function, if there are no records in it (the response is false) it is going to make the Available asset read only and it is going to show the rich text variable.

This is a solution if you are using a Catalog item if you are on back-end form you can do the same but replace the variable with a field message 

g_form.showFieldMsg('availabele_asset','Please contact IT ','info');

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan