The CreatorCon Call for Content is officially open! Get started here.

Access Catalog Item variable from Variable set Client script

kailashthiyagar
Kilo Guru

I have a multi row variable set with one reference field. When i change the value of the reference field in the variable set, i want to update the variable on the parent catalog item. I have written a on change client script and tried to set its value using g_form.setValue but it didnt work and it makes sense. I want to know how we can access it

8 REPLIES 8

Hi,

I dont think that is possible atm. with mrvs. It only works with the "old" variable sets. I'll see if I can dig out something more. Can you give a good use can where you actually need to have this setup where a variable inside a mrvs populates a field outside of the mrvs. Perhaps with the requirements we can come up with a different approach.

//Göran
Feel free to connect with me:
LinkedIn & Twitter
Subscribe to my YouTube Channel
Buy The Witch Doctor's Guide To ServiceNow

 

Hi Goran,

I have same question and use case here is- 

1. MRVS variable 1- start date

2.MRVS variavle 2- end date

3.MRVS variable 3 date difference

if (date difference > 3 days) then set approval flag to yes     // approval flag is a variable on catalog item

else keep on adding rows in MRVS

 

Any suggestion would be highly appreciated.

Thanks in advance !!

Alexis Diaz Alc
Giga Guru

Joe72
Tera Contributor

The only way I've been able to do this is DOM manipulation and angular:

    //Frame view
    if (typeof angular == "undefined")
        accountJSON = window.parent.g_form.getValue('account_options');
    //Service Portal
    else {
        var catItem = this.angular.element('#sc_cat_item\\.do').scope();
        var parent_g_form = catItem.getGlideForm();
        accountJSON = parent_g_form.getValue('account_options');
    }

The top code is for the backend whereas the bottom is for Service Portal. This is not ideal and could easily change in an upcoming release, but it's working as of Paris.

Has anyone come up with a less hacky solution?