Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Catalog Client Script to change display label value?

MBarrott
Mega Sage

I have an onChange Catalog Client Script which is checking for change to a name field. 

 

I would like to then have this name display within the display value variable I have on the form. 

 

I've tried g_form.setValue('display_var', newValue); and g_form.setLabelOf('display_var', newValue); but neither have updated the display label. 

 

What's the scripting solution to this?

1 ACCEPTED SOLUTION

MBarrott
Mega Sage

For anyone curious I did some digging and ServiceNow specify that this actually shouldn't be possible and is expected behavior. 

 

This has been addressed on KB0758098: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0758098

View solution in original post

16 REPLIES 16

@MBarrott 
could you please create the function changeFieldLabel and use that one instead?


Thanks & Best regards,
Medi

@Medi C I tried it but it came back with a Javascript error. 

Could you please share the error message/screenshot?


Thanks & Best regards,
Medi

Hi @MBarrott 

 

I tried reproducing your issue. g_form.setLabelOf() method is working fine for me on Service Portal but not on Native UI. Refer below screenshots:

 

AmitVerma_0-1741659218066.png

 

Before Client Script Execution:

AmitVerma_1-1741659272813.png

 

After Client Script Execution:

AmitVerma_2-1741659329198.png

 

Thanks and Regards

Amit Verma

Thanks and Regards
Amit Verma

Hi @vermaamit16 - this is what I did but it wasn't for a single-line text field (that works in the Service Portal). 

 

The variable I'm trying to change dynamically is a Display label - Plain text.