Need to show active users in a variable for one particular catalog item

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, variable set is included in 24 catalog but for only one catalog item i need to show the users who are active and emp id is empty in the requested for (reference to user table) variable.

 

I tried writing a onload script but it is not working.

script written in catalog item

 
function onLoad() {
   var catItem = g_form.getParameter('sysparm_id');
   if (catItem =='f6976993ebc90210b2bff25e1bd0cde4'){
    g_form.setReferenceQualifier('requested_for','active=true^employee_numberISEMPTY');
   }else {
    g_form.setReferenceQualifier('requested_for', '');
   }
   
}

But i get this annotation This catalog client script is not VA supported due to the presence of the following variables in the script: g_form.getParameter, g_form.setReferenceQual

4 REPLIES 4

Huynh Loc
Mega Sage

Hi @suuriyas ,
Instead of using a client script, please use an advanced reference qualifier on your variable
Example:
image.png

If this response was helpful, please consider marking it as Correct and Helpful. You may mark more than one reply as an accepted solution.

 

HI @Huynh Loc ,

 

Thanks for replying.

 

Yeah, but we want to achieve this via client script only.

Tanushree Maiti
Kilo Patron

Hi @suuriyas , 

 

For catalog items, the “Requested For” variable should be mandatory, as it helps track on whose behalf the request is being made.

 

Could you confirm whether, in your instance, the “Requested For” variable is not mandatory? If so, where is this requirement coming from?

 

Also, for the “Requested For” reference variable, if you set the reference qualifier to Active = true, it will always display only active users.

 

Are you trying to check cases where the “Requested For” field is empty for legacy records (such as sc_req_item and sc_task)?

If that’s the case, you can write a fix script or background script to retrieve the list of such records.

 

 

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