New help on changing the variable label text.

Lisa Goldman
Kilo Sage

Hello,

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.  Could someone please help? 

Thank you

9 REPLIES 9

DrewW
Mega Sage
Mega Sage

Is there a reason you do not just go to the variable definition and change it there?

Hi @DrewW 

 

Thank you for your suggestion.  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?

 
 
 
 

Hi @Lisa Goldman ,

The first parameter of the setLabelOf method is the name of the variable (looks like you are passing the label for the variable)

 

g_form.setLabelOf('Old Phone Number',/*update this with name of the Variable*/ ,'New Phone Number')

 

If the issue still persists check for any errors in the browser console and share the screenshot of those errors.

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hi @Chaitanya ILCR 

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.

 

I'm testing this code in a Multiple Choice variable, when a option is select, the text label should change to 'New Phone', but it did not.

 

 

function onChange(control, oldValue, newValue, isLoading) {
    
	
	if (newValue == 'yes') {
        g_form.setLabelOf('old_phone', 'New Phone');
    } else {
        g_form.setLabelOf('old_phone', 'Old Phone');
    }
}