How to change variable names dynamically inside variable's section of the RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 02:22 AM
Hi,
Below is the two variables used in service catalog
1. Name - Single Line Text
2. CI Class - Dropdown (Choices : Application, Server)
My Requirement is,
- If I select "Application" choice in the CI class dropdown, the "Name" Label should change to "Application Name"
- If I select "Server" choice in the CI class dropdown, the "Name" Label should change to "Server Name"
I tried below code in client script:
***** Application choice*****
var field1 = 'u_name'; // u_name is the database name for the variable
var labelElement1 = $('label_' + g_form.getControl(field1).id).select('label')[0];
labelElement1.innerHTML = 'Application Name'; // Application Name is the label name.
*****Server choice*****
var field = 'u_name'; // u_name is the database name for the variable
var labelElement = $('label_' + g_form.getControl(field).id).select('label')[0];
labelElement.innerHTML = 'Server Name'; // Server Name is the label name.
It is working in Service Catalog form. But not working inside variable's tab of the submitted RITM.
Can anyone help me to solve this requirement?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 02:28 AM
may i know why do you want to change the variable label after the RITM creation ? may i know the exact use case ?
another point you are doing DOM manipulation which is not good practice, again if you will use the catalog on service-portal, it will not work.
Service-now recommended avoid DOM as much as possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 02:43 AM
Hi Harsh, there is no specific reason for this because that is my requirement
(1) On CI form change the "Name" title to "Application Name" or "Server Name" depending on the class chosen. People are entering their own name here for some reason.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 02:48 AM
instead of changing the label, add one variable to populate the class name.
it will be easy to maintain as well, i would not suggest to go with DOM manipulation.