Rich Text Label not updating in RITM (Variable Editor) but works in Service Portal

Ankit Balapure
Tera Contributor

Hi,

I’m facing an issue with dynamically updating a Rich Text Label in RITM and SC Task forms.

I am using the g_form.setLabelOf() method to update the label text dynamically. It works as expected in the Service Portal, but it is not working at the RITM and SC Task level in the platform UI.

Also, I would like to avoid any DOM manipulation-based solution, as DOM manipulation is not used or supported in our organization.

Could anyone please suggest if there is any supported or recommended solution for this scenario?

Thanks.

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Ankit Balapure 

see this

g_form.setLabel does not work on a Label type variable on Service Portal 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Ankit Balapure
Tera Contributor

Hi @Ankur Bawiskar,

I’m not sure this addresses my question.

To clarify, I have a variable of Rich Text type, and I am using the setLabelOf() method to dynamically set its content. This is working correctly in the Service Portal, but it is not working at the RITM and SC Task level in the Platform UI.

In your response, you mentioned using the setLabel() function, but my requirement is specifically related to updating Rich Text content dynamically, not just a plain label.

Could you please suggest the correct or supported approach for achieving this in RITM/SC Task without using DOM manipulation?

Thanks.

jcmings
ServiceNow Employee

How have you configured this in the service portal? Via a catalog client script/UI policy? Did you also create a onLoad client script on RITM table and on SC Task table?

Ankit Balapure
Tera Contributor

Hi @jcmings,

I have just created the catalog client script type is on change. I want to set the text according to the value change of another variable and below is the script which I am using currently and not working on the service portal but not working on the RITM and SC task.

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {
        return;
    }

    var form = typeof g_sc_form != "undefined" ? g_sc_form : g_form;

    if (!form) return;

//Either of methods are not working on RITM and SC Task Level
	form.setLabelOf('select_type_of_service_needed_options',''); 
	form.setLabel('select_type_of_service_needed_options','');

    var catItemSysId = form.getUniqueValue();
    var typeOfNetwork = form.getValue('select_the_type_of_network_related_to_your_request');

    var table = 'option_table';
    var query = 'u_catalog_item=' + catItemSysId +
        '^u_menu_type=type_of_service_needed' +
        '^u_menu_value_1=' + typeOfNetwork +
        '^u_menu_value_2=' + newValue;

    var ga = new GlideAjax('ScriptIncludeName');
    ga.addParam('sysparm_name', 'fetchRecordFieldsGeneric');
    ga.addParam('sysparm_table', table);
    ga.addParam('sysparm_query', query);

    ga.getXMLAnswer(function(response) {
        var answer = JSON.parse(response);
        var instructionHelpTxt = answer.u_instrunctions;

//Either of methods are not working on RITM and SC Task Level
        form.setLabelOf('select_type_of_service_needed_options', instructionHelpTxt);
        form.setLabel('select_type_of_service_needed_options', instructionHelpTxt);
    });
}