- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 12:20 PM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 03:20 PM
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());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 02:44 PM
It might be you use the display value like "Laptop" in your script. Can you try:
javascript: new getNameFromCategoryNew().getName(current.variables.model_category.getDisplayValue());
For scope try adding global (or the scope your script include is in) to it like this:
javascript: new global.getNameFromCategoryNew().getName(current.variables.model_category.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 02:47 PM
I tried that (including getDisplayValue), and I also tried using the following, but neither worked. As mentioned, this did work from a background script:
javascript: new getNameFromCategoryNew().getName("Laptops")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 02:50 PM
I updated with global option. Can you try that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 02:57 PM
I tried moving both the table and the record producer to the global scope and running, unfortunately results were the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 03:02 PM
Can you add logs to the Script include? (in scope use gs.info()).
Can you see if the script include gets called and the result?