Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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 

 

I tried with Label type field as well and it is working on Service Portal. Refer below screenshots:

AmitVerma_0-1741845741209.png

 

AmitVerma_1-1741845777802.png

 


Please mark this response as correct and helpful if it assisted you with your question.

@Amit Verma Could you show the script you're using for the label change? Curious why mine wouldn't be updating correctly. 

@MBarrott 

are you saying it's working in native but not in portal?

refer my solution here which you can enhance

How to make text of Label type in Bold 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

Akshay Bhaskar
Kilo Sage

@MBarrott / @Ankur Bawiskar / @Amit Verma - 

Posting here since this is the latest thread I came across discussing about the setLabelOf() method. 

While you can manipulate the label of a field within a catalog form using the setLabelOf(), the same onLoad script would not work on the RITM and this is my experience currently. 

Could you please validate if I'm missing something here - I have a field in a catalog form called 'directorships'. The label of the field is 'Mention the Directorships', and I'm using an onLoad client script to change the label of this field to 'Hello. This is the directorships label.' Whilst the latter label is displayed as expected on the portal, the submitted RITM still shows the old label. 


Regards,
Akshay