how to display reference field variable value starts with the letter X

BanuMahalakshmi
Tera Contributor

HI,

I have 2 variables account(choices - abc, def), account name(reference data type - the value coming from sys_user table).

 

if the account value abc, the account name displays values where samaccountname starts with x.

if the account value def, the account name displays values where samaccountname starts with Y.

 

User can use wildcard search on the fields being displayed.

Thanks.

1 REPLY 1

Dnyaneshwaree
Mega Sage

Hello @BanuMahalakshmi ,

1. You can create onchange/ onload client script on the required table.
2. get value of both choice and reference fields (if sys_id then use getDisplayValue()) use two seperate variables for reference field to get value starts with x and y seperately. you can use indexOf() > -1 or starts with in condition.
3. use condition if choice = abc then set reference field value = var of x and else if vice versa.

You can refer below article that was exactly reverse to your requirement:
https://www.servicenow.com/community/developer-forum/set-choice-field-based-on-the-reference-field/m...
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0785188

If my solution helps you any way then mark it as accepted and helpful.

Thank You!!


Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru