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

Populating empty cells in MVRS within Case

martinkruml
Tera Guru

Hello,

 

We have a catalog item, which is using 2 MVRS and we have a requirement, that if the cell in a row is empty, we want to either completely hide it or populate it with N/A text. 

 

How this would be achievable? Because I tried to do checks within script for catalog item, to check if field is empty, but it is still not populating.

 

Any other idea?

Thanks!

1 REPLY 1

Nishant8
Giga Sage
Giga Sage

Hello @martinkruml, If you wish to replace null variables with 'N/A' then you can probably write a Catalog Client Script on Load that Applies To 'A Catalog Item' and select the desired View - Catalog Item/Request Item/Catalog Task. Here is the script

function onLoad() {
    var mrvsValue = g_form.getValue('<MRVS_Name>');
    if (mrvsValue) {
        var obj = JSON.parse(mrvsValue);
        for (var i = 0; i < obj.length; i++) {
            for (var key in obj[i]) {
                if (obj[i][key] === null || obj[i][key] === "") {
                    obj[i][key] = "N/A";
                }
            }
        }
    }
    g_form.setValue('<MRVS_Name>', JSON.stringify(obj));
}

Regards,

Nishant