IF no user id entry found on reference variable we need to show message

pujitha K
Tera Contributor

 

Hi Team,

 

We currently have two variables in the form:

  • Select User – a reference variable pointing to the User table
  • User ID – a single-line text variable

The expected behavior is as follows:

  • When the user information entered in Select User is not found, the system should display the following error message:
    “User BC ID not found, please introduce data manually.”

  • After displaying this message:

    • The Select User reference variable should be hidden
    • The User ID text variable should be displayed, allowing the user to enter the details manually

Please help me to achieve the requirement.

 

Thanks,

Pujitha

4 REPLIES 4

Dr Atul G- LNG
Tera Patron

Hi @pujitha K 

As per my experience, the Reference field does not work like this. If a user is not found, it will not show any record.

What you can do instead is create a new checkbox variable, for example “User Not Found.” If this is selected, you can redirect the user to another record producer, page, or catalog item to handle the case appropriately.

I had a similar situation when working with the Location table, and this approach worked well.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron

@pujitha K 

This doesn't look like a valid business requirement.

Your variable is reference to sys_user means whatever record the user selects that user is available in sys_user

Then that message won't be shown

I will request to discuss this requirement with your customer

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@pujitha K 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Mega Patron

Hi @pujitha K ,

 

Its not that perfect requirement .

 

Still you can try this way.

1) Create a UI policy /Onload catalog client script 

which will  hide User_id single line text from form during onload.

 

2. Create a OnSubmit Catalog Client script  to validate whether select_user variable having value or not . If  no value , make User ID mandatory.

 

Note : Select User should not be Mandatory variable, else, this solution will not work.

   

TanushreeMaiti_0-1777041284092.png

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: