Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to change the label of variable set

PRAGHATIESH S
Tera Expert

Hi Team,

I have already created one variable set "Information" , now I want to reuse the same variable set on another record producer but the label should be different. 

 

Can anyone help here, how to change the label of variable set.

2 REPLIES 2

Yashsvi
Kilo Sage

Hi @PRAGHATIESH S,

please check below link:

https://www.servicenow.com/community/now-platform-forum/how-to-update-the-variable-label-dynamically...

Thank you, please make helpful if you accept the solution.

Satishkumar B
Giga Sage
Giga Sage

Hi @PRAGHATIESH S 

try this:

 

 

(function() {
    var variableSysID = '4183304f4f9b0200fbb73fb28110c75a'; // Your variable set sys_id

    function changeVariableSetLabel(variableSysID, newLabel) {
        var labelElement = gel('label_IO:' + variableSysID);
        if (labelElement && labelElement.childNodes[0] && labelElement.childNodes[0].childNodes[1]) {
            labelElement.childNodes[0].childNodes[1].innerHTML = newLabel;
        }
    }

    var producerSysId = g_form.getUniqueValue();
    if (producerSysId === 'your_record_producer_sys_id') { // Replace with your record producer sys_id
        changeVariableSetLabel(variableSysID, 'My new Label Text Here');
    }
})();

 

 

 

-----------------------------------------------------------------------------------

Please consider marking my reply as Helpful  👍and/or Accept Solution ✔️, if applicable. Thanks!