<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: New help on changing the variable label text. in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207194#M1187432</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/364405"&gt;@DrewW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I'm encountering is with the Item and Catalog Task in the fulfiller view.&lt;/P&gt;&lt;P&gt;It works perfectly fine in the self-service portal without any errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are the steps I tested in my PDI. When you have a chance, you can replicate it in your PDI to check if you're experiencing the same issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 1 - Create a text variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_0-1741990527128.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426943i706E4D68FC9D8C09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_0-1741990527128.png" alt="LisaGoldman_0-1741990527128.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 2 - Create a Multiple choice variable with one value "yes"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_1-1741990560981.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426944iA82926AFA68B455F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_1-1741990560981.png" alt="LisaGoldman_1-1741990560981.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 3 - onChange Client Script code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_2-1741990673922.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426945iDEDFB3367A94B4FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_2-1741990673922.png" alt="LisaGoldman_2-1741990673922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    
	
	if (newValue == 'yes') {
        g_form.setLabelOf('old_phone', 'New Phone');
    } else {
        g_form.setLabelOf('old_phone', 'Old Phone');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Mar 2025 22:18:40 GMT</pubDate>
    <dc:creator>Lisa Goldman</dc:creator>
    <dc:date>2025-03-14T22:18:40Z</dc:date>
    <item>
      <title>New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206260#M1187191</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I’m using g_form.setLabelOf('Old Phone Number', 'New Phone Number') method to dynamically change the label of a variable. While the label changes successfully on the portal, it doesn't update in the desktop view.&amp;nbsp; Could someone please help?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 00:07:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206260#M1187191</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T00:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206263#M1187194</link>
      <description>&lt;P&gt;Is there a reason you do not just go to the variable definition and change it there?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 00:18:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206263#M1187194</guid>
      <dc:creator>DrewW</dc:creator>
      <dc:date>2025-03-14T00:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206378#M1187210</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/364405"&gt;@DrewW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your suggestion.&amp;nbsp; We also can create two separate variables and hide or display them based on certain conditions. However, we would like to know if there is a way to dynamically change the label text using a client script. If the g_form.setLabelOf method works on the portal, why isn't it functioning in the fulfiller view?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Mar 2025 05:56:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206378#M1187210</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T05:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206426#M1187222</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/264835"&gt;@Lisa Goldman&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The first parameter of the setLabelOf method is the name of the variable (looks like you are passing the label for the variable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;g_form.setLabelOf('Old Phone Number',/*update this with name of the Variable*/ ,'New Phone Number')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If the issue still persists check for any errors in the browser console and share the screenshot of those errors.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please mark my answer as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#008000"&gt;helpful/correct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;if it resolves your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Regards,&lt;BR /&gt;Chaitanya&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 06:44:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206426#M1187222</guid>
      <dc:creator>Chaitanya ILCR</dc:creator>
      <dc:date>2025-03-14T06:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206871#M1187348</link>
      <description>&lt;P&gt;I'm assuming you checked to make sure that the client script is set to run on the Item and cat task correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also have you checked the browser console to see if there is an error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 14:05:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3206871#M1187348</guid>
      <dc:creator>DrewW</dc:creator>
      <dc:date>2025-03-14T14:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207188#M1187430</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/24805"&gt;@Chaitanya ILCR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original post was only an example. Below is the code I used to test it in my PDI. It works fine in the portal without any error messages. However, in the fulfiller view (RITM, TASK), the label did not change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm testing this code in a&amp;nbsp;&lt;A class="" href="https://dev247281.service-now.com/item_option_new.do?sys_id=4b85e7f0835212107b27b3a6feaad34a&amp;amp;sysparm_record_target=item_option_new&amp;amp;sysparm_record_row=3&amp;amp;sysparm_record_rows=4&amp;amp;sysparm_record_list=cat_item%3Dbd56745c833512107b27b3a6feaad300%5EORDERBYorder"&gt;Multiple Choice&lt;/A&gt;&amp;nbsp;variable, when a option is select, the text label should change to 'New Phone', but it did not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    
	
	if (newValue == 'yes') {
        g_form.setLabelOf('old_phone', 'New Phone');
    } else {
        g_form.setLabelOf('old_phone', 'Old Phone');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 22:10:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207188#M1187430</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T22:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207194#M1187432</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/364405"&gt;@DrewW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I'm encountering is with the Item and Catalog Task in the fulfiller view.&lt;/P&gt;&lt;P&gt;It works perfectly fine in the self-service portal without any errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are the steps I tested in my PDI. When you have a chance, you can replicate it in your PDI to check if you're experiencing the same issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 1 - Create a text variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_0-1741990527128.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426943i706E4D68FC9D8C09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_0-1741990527128.png" alt="LisaGoldman_0-1741990527128.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 2 - Create a Multiple choice variable with one value "yes"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_1-1741990560981.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426944iA82926AFA68B455F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_1-1741990560981.png" alt="LisaGoldman_1-1741990560981.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 3 - onChange Client Script code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LisaGoldman_2-1741990673922.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/426945iDEDFB3367A94B4FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LisaGoldman_2-1741990673922.png" alt="LisaGoldman_2-1741990673922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    
	
	if (newValue == 'yes') {
        g_form.setLabelOf('old_phone', 'New Phone');
    } else {
        g_form.setLabelOf('old_phone', 'Old Phone');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 22:18:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207194#M1187432</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T22:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207196#M1187434</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/24805"&gt;@Chaitanya ILCR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached in an update set if you would like to try it.&amp;nbsp; Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 22:33:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207196#M1187434</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T22:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207197#M1187435</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/364405"&gt;@DrewW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached in an update set if you would like to try it in your PDI.&amp;nbsp; Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 22:34:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207197#M1187435</guid>
      <dc:creator>Lisa Goldman</dc:creator>
      <dc:date>2025-03-14T22:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: New help on changing the variable label text.</title>
      <link>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207257#M1187448</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/264835"&gt;@Lisa Goldman&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Looks like it's not a straightforward solution to set a label for catalog items&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.servicenow.com/kb?id=kb_article_view&amp;amp;sysparm_article=KB0758098" target="_blank"&gt;https://support.servicenow.com/kb?id=kb_article_view&amp;amp;sysparm_article=KB0758098&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://servicenowguru.com/ui-scripts-system-ui/modifying-label-form-fields-client-scripts/" target="_blank"&gt;https://servicenowguru.com/ui-scripts-system-ui/modifying-label-form-fields-client-scripts/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used these and update the client script as below with isolate script as false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
    var actualLabel = 'Old Phone:';

    var tableName = g_form.getTableName();
    if (tableName == 'sc_req_item' || tableName == 'sc_task') { //for RITM and SC Task
        var stb = Array.from(document.getElementsByClassName('sn-tooltip-basic'))
        stb.forEach(function(item) {
            var role = item.getAttribute('role');
            if (role == 'heading' &amp;amp;&amp;amp; item.innerHTML == actualLabel) {
                item.innerHTML = 'New Phone';

            }

        });
        return;

    }

    try { //for native UI
        var labelElement = $('label_' + g_form.getControl('old_phone').id);
        labelElement.select('.sn-tooltip-basic').forEach(function(elmt) {
            if (newValue == 'yes')
                elmt.innerHTML = 'New phone';
            else
                elmt.innerHTML = actualLabel;

        });
    } catch (e) { //for portal
        if (newValue == 'yes')
            g_form.setLabelOf('old_phone', 'New phone');
        else
            g_form.setLabelOf('old_phone', actualLabel);
    }

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also attaching the XML of updated version of client script.&lt;/P&gt;&lt;P&gt;import it and try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but at this point it's easier to create/maintain two separate variables for this as this involves DOM manipulation which is not recommended and might break with future releases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please mark my answer as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#008000"&gt;helpful/correct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;if it resolves your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Regards,&lt;BR /&gt;Chaitanya&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Mar 2025 03:22:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/new-help-on-changing-the-variable-label-text/m-p/3207257#M1187448</guid>
      <dc:creator>Chaitanya ILCR</dc:creator>
      <dc:date>2025-03-15T03:22:24Z</dc:date>
    </item>
  </channel>
</rss>

