How to populate a variable in mrvs from record producer

Community Alums
Not applicable

Hi Team,

 

We have a record producer and also a mrvs within the record producer.

There is a field tax_code in record producer whose value we want to fetch and populate the same to the tax_code1 in mrvs after we click on Add rows in mrvs.

Any hints?

1 ACCEPTED SOLUTION

Cool!  Unfortunately, we have to do that the longer way (for now?).

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

You can use a Catalog Client Script like this that applies to the MRVS

function onLoad() {
    g_form.setValue('tax_code1', g_service_catalog.parent.getValue('tax_code'));
}

Community Alums
Not applicable

Hi Bradd,

 

That is working fine thanks

But I need to fetch the display value as tax_code is a reference field.Hence I am using the below

function onLoad() {
    //Type appropriate comment here, and begin script below
 

g_form.setValue('tax_code1', g_service_catalog.parent.getDisplayValue('tax_code'));
}
 
But its giving browser error

Hello @Community Alums ,

 

The g_service_catalog API only has the getValue() method. It's not the same as g_form. You'll have to make "tax_code1" a Reference variable, same as "tax_code".

 

Regards,

Robert

Community Alums
Not applicable

@Brad Bowman  its working now 🙂  I used GlideAjax with your syntax

    var ga = new GlideAjax('ClientSideUtils');
    ga.addParam('sysparm_name', 'fetchTaxCode');
    ga.addParam('sysparm_taxcode', g_service_catalog.parent.getValue('tax_code'));
    ga.getXMLAnswer(populatetaxcode);

    function populatetaxcode(answer) {
        g_form.setValue('tax_code_gl', answer);

    }