Parsing through an mrvs

erin-marie
Tera Contributor

I am working on a workflow script to take a Multi-Row Variable Set from a catalog item.  Create an array to get the data so that I can transfer the display name of the field POAM to a CHG.  Everything is working great for creating the CHG from the catalog item, except for this one last piece.  The POAM field on the CHG form is a string field and I just need the POAM IDs, not the other information.

 

Here is the section of code.  

 

 // POAM START    
    var mrvspoam = current.variables['decommission_poam_details'];
    var mrvspoam_length = mrvspoam.getRowCount();
    var poam, poam_arr = [];
    gs.log('decom mrvspoam: ' + mrvspoam + ' | mrvspoam length: ' + mrvspoam_length); // debug

    // loop through poam's
    for (var i = 0; i < mrvspoam_length; i++) {
        poam = mrvspoam.getRow(i); // next poam listed
        gs.log('decom mrvs in loop poam: ' + poam + ' | poam ref: ' + poam.sc_decomm_poam_id);


        var gr = new GlideRecord('u_poam');
        if (gr.get(poam.sc_decomm_poam_id.toString())) {
            poam_arr.push(poam.getDisplayValue());
        }


    } // end for loop

    gs.log('decom poams len: ' + poam_arr.length + ' | dump: ' + poam_arr.join(','));

    // copy remaining poam's into the poam fields
    if (poam_arr.length > 1)
        change.u_poa_m_ids = poam_arr.join('\n');



    // POAM END
 
And here are the two logs created from my debugging.  The first array works fine, the second ione appears to as well and nothing is transferring to the CHG.
 
erinmarie_0-1758064376758.png

 

 
 
1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Hello,

Your poam_arr is showing empty in the log so you need to look at the GlideRecord.  Is your u_poam table in the Global or same scope as the Catalog Item? When pushing the value to the poam_arr I think you meant:

poam_arr.push(gr.getDisplayValue());

If this doesn't show values in the third / poam_arr log, add a log within the if block of the GR to make sure a record is found.  Once you've confirmed this, try something more like:   

poam_arr.push(gr.getValue('u_name'));

 or whatever your display value field name is on this table.