MRVS - pass variable from the parent and use it in reference qualifier

thebananek
Tera Contributor

 

Have anyone fixed this problem? Do you have any suggestions?

  • Catalog item variable  var1
  • MRVS (Multi Row Variable Set)
    • inside it → reference variable

Goal:
Use var1 (outside MRVS) inside the reference qualifier of the MRVS reference field.

In docs I see:

 

1 ACCEPTED SOLUTION

Brad Bowman
Mega Patron

One approach is detailed in this article (Scene 2) 

https://www.servicenow.com/community/servicenow-ai-platform-articles/yes-you-can-effectively-set-or-... 

 

Another approach could be to first create an onLoad Catalog Client Script that applies to the Catalog Item

function onLoad() {
    if (this) {
        this.cat_g_form = g_form;
    }
}

Then create an onLoad Catalog Client Script that applies to the MRVS, leaving the reference qualifier on the variable itself empty:

function onLoad() {
    if (this) {
        var ciClass = this.cat_g_form.getValue('ci_class');
        var filter = g_list.get('field');
        filter.setQuery('active=true^name=' + ciClass + '^internal_type=string');
    }
}

Where 'ci_class' is the name of the catalog item variable, and the setQuery value is whatever makes sense for your use case.

View solution in original post

1 REPLY 1

Brad Bowman
Mega Patron

One approach is detailed in this article (Scene 2) 

https://www.servicenow.com/community/servicenow-ai-platform-articles/yes-you-can-effectively-set-or-... 

 

Another approach could be to first create an onLoad Catalog Client Script that applies to the Catalog Item

function onLoad() {
    if (this) {
        this.cat_g_form = g_form;
    }
}

Then create an onLoad Catalog Client Script that applies to the MRVS, leaving the reference qualifier on the variable itself empty:

function onLoad() {
    if (this) {
        var ciClass = this.cat_g_form.getValue('ci_class');
        var filter = g_list.get('field');
        filter.setQuery('active=true^name=' + ciClass + '^internal_type=string');
    }
}

Where 'ci_class' is the name of the catalog item variable, and the setQuery value is whatever makes sense for your use case.