Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to add a Reference qual condition via an Onchange Client Script

Magali Legaspi
Tera Contributor

Hi all.

 

I'm having trouble with this. What I need to do is with an onchange client script, I have to add a Reference qual condition on a field that references the user table, that will change depending on the user's selection on another field.

 

Is this possible, to add a reference qualifier condition via Catalog Client Scripts? if so if you could give me an example.

 

Thanks in advance!!

1 ACCEPTED SOLUTION

For future users with a similar requirement, my solution was:

 

Script Include returns reference qualifier string e.g. "sys_idINx,y,z".

On the reference field, Type Specifications > Use reference qualifier > Advanced.

In the Reference qual field: 

 

javascript: new ScriptIncludeName().FunctionName();

 

 

Example:

 

javascript: new PositionUtils().getPeopleLeaderUsersRefQual();

 

 

Note: Replace : with an actual colon. Comment keeps mangling the character.

View solution in original post

8 REPLIES 8

For future users with a similar requirement, my solution was:

 

Script Include returns reference qualifier string e.g. "sys_idINx,y,z".

On the reference field, Type Specifications > Use reference qualifier > Advanced.

In the Reference qual field: 

 

javascript: new ScriptIncludeName().FunctionName();

 

 

Example:

 

javascript: new PositionUtils().getPeopleLeaderUsersRefQual();

 

 

Note: Replace : with an actual colon. Comment keeps mangling the character.

Maik Skoddow
Tera Patron

Hi @Magali Legaspi 

no, that is not possible. Reference Qualifier are defined in the Dictionary on server-side only.

Maik

Sitrix
Tera Guru

Here ya go.

 

https://servicenowthink.wordpress.com/2021/02/05/how-to-modify-reference-qualifiers-with-catalog-cli...

 

Yes, you can add or modify a script include via advanced ref.qualifer - but in my case the variable set is used on hundereds of items. Adding code to the script include for "one off" uses will quickly turn it into a mass. Much better to have the change local to the catalog item... imo.

Not applicable

this article worked for me:
How to modify Reference Qualifiers with Catalog Client Scripts – ServiceNow – ServiceNow Think (word...

 

and this is the onChange client script:

var resetFilter = 'active=true^nameISNOTEMPTY^emailISNOTEMPTY^EQ';
var dynamicFilter = g_form.getValue('your other text var holding encoded query').toString().trim();
var gg = g_list.get('your ref var name'); // GlideList2 object
gg.setQuery(newValue == '' ? resetFilter : dynamicFilter);