setLabelOf() does not work on an RITM

Akshay Bhaskar
Kilo Sage

I've been working on some form changes, and I've realised that 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. 

@Ankur Bawiskar

1 ACCEPTED SOLUTION

Akshay Bhaskar
Kilo Sage

For someone looking at this post in the future - 

Summary - 

We encountered an issue where long checkbox and multiple-choice labels (exceeding 255 characters) could not be stored in the variable Question attribute. To work around this, we tried updating labels dynamically using g_form.setLabelOf() in an onLoad client script. While this correctly updated the label on the catalog form, it did not reflect in the RITM, causing confusion during review. After investigation and confirmation from ServiceNow ( @Epapra Polugari), here are the key takeaways:


Root Cause: 

  • g_form.setLabelOf() only changes the label on the client-side catalog UI.

  • It does not update the backend variable question, so RITMs, SCTASKs, notifications, approvals, exports, etc., continue to show the original (trimmed) label.

  • This is a platform limitation and expected behaviour.

Recommended Approaches:

  • Use a Rich Text Label variable

    • Add a Rich Text Label (or similar descriptive variable) above/below the checkbox.

    • No character limit; displays correctly in both catalog forms and RITMs.

  • Use Help Text or UI Policy Messages

    • Keep the variable label short.

    • Place the long compliance explanation in:

      • Help text

      • A Catalog UI Policy field message

      • A Rich Text/HTML container variable

  • Avoid using setLabelOf() for data that must be stored or audited.
    It only affects the browser view and does not propagate to backend records.

Regarding Extending the Question Attribute Length

  • Increasing the max length of the Question field is not recommended.

  • The variable label is used across the platform (RITMs, tasks, approvals, exports, PDFs, emails).
    Longer text can:

    • Impact performance (label rendering happens frequently)

    • Reduce readability across downstream processes

Resolution - 1.png

Resolution - 2.png

Resolution - 3.png

image.png

 

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Akshay Bhaskar 

it doesn't work in backend and only works in catalog form

you might have to use DOM manipulation for this

Note: DOM manipulation is not recommended

check this link which has script from Chaitanya

New help on changing the variable label text. 

AnkurBawiskar_0-1764742729528.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Akshay Bhaskar 

Thank you for marking my response as helpful.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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