Using a client script to dynamically change a label makes required asterisk disappear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2018 08:02 AM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2018 08:58 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2018 11:34 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2018 07:16 AM
Thanks for the quick response.
Unfortunately, that doesn't appear to work in the Service Portal / Service Catalog.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2018 12:19 PM
This works for me.
Is you client script marked as UI Type "All"?