Access current.variables from MRVS?

Maverick E
Tera Guru

I have a situation where I'm trying to access 'current.variables.[variable]' from a reference qualifier within a multi-row variable set. 

There's two fields: Department and Application. 

  • The application field is referencing the 'cmdb_ci_service' table. I've also added a new field on this table called "u_departments_available" list collector. This reference field is INSIDE the MRVS.
  • The department field is not inside of the MRVS. This field is referencing the 'cmn_department' table.

When someone selects a department, I want to filter out applications inside of the Application reference field within the MRVS. e.g. Someone selects "IT" as the department, then only show applications associated to the "IT" department. 

My problem is that I am not able to get the advanced reference qualifier to work. Here is what I have so far:

javascript:"u_departments_availableLIKE"+current.variables.department_ma

"u_departments_available" is a list collector on the 'cmdb_ci_service' table, while 'department_ma' is a reference field on the catalog item OUTSIDE the multi-row variable set. 

It seems I am not able to access the variables on the catalog item from the MRVS reference variable. 

1 ACCEPTED SOLUTION

Jerry4
Mega Contributor

That will be a challenge MRVS is scoped and does not have access to request item variables which are global
but there is access the other way, i had a similar issue with my college and tried a small workaround , unfortunately its a bit dirty solution but works but i`m not sure if it will be fine for your business case.
So, firstly, depended field had to be taken outside of MRVS and as it was a reference we have used a List collector 

In Your case it would look like 

Department - reference to cmn_department
Applications - List collector - reference to cmdb_ci_service with reference qualifier based on Department 

Above should work as both variables are in global scope , and not comes tricky part, 

First of all MRVS with a column Application which would be a reference field to cmdb_ci_service, remember about the difference, Applications (plural)  is list collector, Application (singular in MRVS) that one is a reference 

Next step, make this column in MRVS as Read Only 

step 3 , on Change client script triggered on Applications variable which will push or pull rows from MRVS with prepopulated Application, it can be tricky as you will have to remember about a validation if a row with application sys id already exist and do correct update , specially when we someone will remove entry from Applications list 

Step 4 Unfortunatelly a bit of DOM to remove "Add" / "Remove" buttons from MRVS, main logic is that number of rows in MRVS is controlled by Applications field

 

More less this way user picks department , based on department picks applications and later on can add additional information in MRVS per application if required. 

View solution in original post

2 REPLIES 2

Jerry4
Mega Contributor

That will be a challenge MRVS is scoped and does not have access to request item variables which are global
but there is access the other way, i had a similar issue with my college and tried a small workaround , unfortunately its a bit dirty solution but works but i`m not sure if it will be fine for your business case.
So, firstly, depended field had to be taken outside of MRVS and as it was a reference we have used a List collector 

In Your case it would look like 

Department - reference to cmn_department
Applications - List collector - reference to cmdb_ci_service with reference qualifier based on Department 

Above should work as both variables are in global scope , and not comes tricky part, 

First of all MRVS with a column Application which would be a reference field to cmdb_ci_service, remember about the difference, Applications (plural)  is list collector, Application (singular in MRVS) that one is a reference 

Next step, make this column in MRVS as Read Only 

step 3 , on Change client script triggered on Applications variable which will push or pull rows from MRVS with prepopulated Application, it can be tricky as you will have to remember about a validation if a row with application sys id already exist and do correct update , specially when we someone will remove entry from Applications list 

Step 4 Unfortunatelly a bit of DOM to remove "Add" / "Remove" buttons from MRVS, main logic is that number of rows in MRVS is controlled by Applications field

 

More less this way user picks department , based on department picks applications and later on can add additional information in MRVS per application if required. 

Brad Bowman
Kilo Patron
Kilo Patron

Here's another way to use catalog item variables in a MRVS reference qualifier

https://www.servicenow.com/community/now-platform-articles/yes-you-can-effectively-set-or-update-a-r...