Using a client script to dynamically change a label makes required asterisk disappear

kb22
Kilo Contributor

Hi All,

I'm using a client script to alter the text label of a field.

var field = 'wfe_senior_director'; // wfe_senior_director is the database name for the variable

 var labelElement = $('label_' + g_form.getControl(field).id).select('label')[0];

   labelElement.innerHTML = "Who is the requested for's AVP or VP?";

 

The script functions correctly, but once the label is changed, the mandatory field asterisk is no longer visible.

Does anyone know how to fix this?

Kevin Brown

6 REPLIES 6

Jace Benson
Mega Sage

There's a g_form method to do this;

g_form.setLabelOf('comments', 'Who is the requested for\'s AVP or VP?');

I'd use this as SN ensures that method should work on both SP and Desktop, and also, that it works with mandatory indicators.

Link to my post with all the methods including setLabelOf

hello jacebenson,

 

were you able get this method setLabelOf() working in Service Portal / Service Catalog ?

i understand from docs that this method is not supported.

 

can you please help me here ?

thanks,

Mahesh.

kb22
Kilo Contributor

Thanks for the quick response.

Unfortunately, that doesn't appear to work in the Service Portal / Service Catalog.

This works for me.

Is you client script marked as UI Type "All"?