How to add Reference Qualifier to Record Producer Variable

Christine30
Tera Guru

Hello:

I have a script include which returns a list of Product Model (cmdb_model) sys_ids, and an associated dynamic filter.  I am able to use the dynamic filter to filter a List View.  I've attached the script include and related screenshots.

Now, I would like to use the same dynamic filter on a record producer variable which is a reference to the Product Model table,  but am unable to do this.  No dynamic filters are available for the record producer variable (see first screen shot below). 

I've tried to use this advanced reference filter instead of a dynamic filter :  "javascript: new getNameFromCategoryNew().getName("Laptops")", also with no success. 

I would also like to change the "hard-coded" "Laptops" argument to be the category selected by the user, and held in another record producer variable named model_category.  I have tried "javascript: new getNameFromCategoryNew().getName(producer.model_category)", but the value does not seem to be passed to the script include. 

Thank you for any help.

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Do you have the logs in the Script include? What do they log when you use this?:

javascript: new global.getNameFromCategoryNew().getName(current.variables.model_category.getDisplayValue());

 

Make sure there are no other variables or variable set named model_category. And change global to the scope your script include is in, for example:

javascript: new scopeapp.getNameFromCategoryNew().getName(current.variables.model_category.getDisplayValue());

View solution in original post

20 REPLIES 20

Willem
Giga Sage
Giga Sage

Can you try:

 javascript: new getNameFromCategoryNew().getName(current.variables.model_category)

 

Make sure to add the Attribute "ref_qual_elements=model_category" on the variable you set the reference qualifier on as well.

I tried, and now the variable is getting passed to the script include. So that problem is solved, thank you.

Unfortunately, the script include still does not work to filter the record producer variable that references the Product Model table.

I'm hoping the screen shot below, which shows selection being made by a user in the record producer, will make this clearer. When Model Category is set to Laptops the script include (called as an advanced filter on Model Name), correctly returns the sys_ids of the two Product Models we have with category "Laptops", appended with 'sys_idIN'.    But, the Model Name selection still includes all Product Models (not just those with category "Laptops").

As noted, the script include does work when used as a dynamic filter outside of the record producer.

Thank you.

 

find_real_file.png

Are the sys_id's the sys_id's you want to be able to select?

then it would be enough to have it like sys_idIN<sy_id's>

 

If it is not the sys_id of the record, but for example model category change it to:

 javascript: 'product_model.' +  new getNameFromCategoryNew().getName(current.variables.model_category)

 

Product model being the field you want to check the sys_id's against. Change it accordingly.

 

So in the end it will say product_model.sys_idIN< sys_id's>

updated