Multi Row variable set one of signle line text field need to display list collector values

pavana3
Tera Expert

Greeting of the Day !

I have used above code its not working for me, catalog i am using work_packages as List collector type  selecting multiple values  this values i am try to display in Multi variable set one of text field that is selected_work_packages (single line text )  and two more check boxs fields available in same multi variable set  for more deatils please find the screenshot. when clicking on ADD action automatically display  work package values in this selected work package text how to do this please help me.

 

Thanks & Regards,

PB

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

It seems like in this case you want to add a row to the MRVS for each value you select in the List Collector, then you can edit each row to check the appropriate boxes.  To do this, since your MRVS has a text field instead of reference, and the list collector stores the sys_ids of the records on the list table, you'll need to call a Script Include to lookup the display value.  Something like this - my example is selecting assets from a list, then populating the MRVS with the display value of the asset and who it's assigned to:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var mrvs = 'asset_mrvs'; // mrvs internal name 
    var gaAsset = new GlideAjax('HardwareDetails'); // script include name
    gaAsset.addParam('sysparm_name', 'fetchAssetDetails'); //script include function name
    gaAsset.addParam('sysparm_deviceids', newValue);
    gaAsset.getXMLAnswer(function(answer) {
        g_form.setValue(mrvs, answer);
    });
}
var HardwareDetails = Class.create(); 
HardwareDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    fetchAssetDetails: function() { 
        var devices = this.getParameter('sysparm_deviceids');
		gs.addInfoMessage(devices)
        var newRecord = [];
        var assetUser = new GlideRecord('alm_hardware');
        assetUser.addQuery('sys_id', 'IN', devices);
        assetUser.query();
        while (assetUser.next()) {
            newRecord.push({
                "asset_name": assetUser.getValue("display_name"),
                "assigned_to": assetUser.getValue("assigned_to")
            });
        }
        return JSON.stringify(newRecord);
    },
    type: 'HardwareDetails' 
});

When you push the new record, you can include your two checkboxes, or if you don't it should add the rows with those empty.  This basically deletes and repopulates the MRVS each time a list collector value is selected/changes so that the MRVS rows will match the list collector values.

 

Hi @Brad Bowman    I am already using Script include and Onchange client script already populating the data here i should not modified Check boxes its showing default values and not added in Script include also ... as per expectation working for me only problem The approval user will modify the check box true or false this data not saved in Task . i am thinking because not added in script include this two checkboxed that is why ? list collator getting values from sys_choice table of business applications ... this list collator whatever selected software names that displaying automatically in Multi row variable text field one row by one row opposite check box 1 check box 2 are displayed ... my issue not solved in Task 2 only it should display this multi row values here if i modify  default values of check box not saving in Task like other variables   what is the solution please .

Thanks & regards,

PB