Is there a way to add a variable into a text field within Catalog Builder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 01:31 PM
I want to add a text field which also includes text which dynamically updates, essentially auto-filling in data in relation to other fields on the form.
The user would put in their name within the "username" field, which is then shown elsewhere to essentially auto build a sentence.
"I, [username] have read the terms and service..."
Is something like that possible?
Another option would be to add a line of text where the user can type into:
"I, [text field] have read the terms and service..."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 01:40 PM - edited 03-07-2025 01:41 PM
Hello @MBarrott
You need to create multiple variables for username value and will be able to set the same value in all of them.
or you can use one HTML type and auto-populate the username in the entire text.
Some additional information: https://www.servicenow.com/community/developer-forum/best-practice-for-duplicating-fields-on-a-recor...
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:05 PM
To insert their name like that, I think you'd need to have a custom widget variable. The server script of the widget would lookup the current user and then display it in the HTML. This is the only way I can think to have it display in a clean, single-line like you are asking for. If you want the user to enter their name into a text box, and then see that in a single-line like you've mentioned, you'd probably need an onChange client script that watches your variable field and updates the single-line variable.
If you aren't as insistent on having the username display there, you could just make this a checkbox and have something to the tune of "By checking this box, I acknowledge that I have read the terms and service..."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:19 PM
You can create a variable like single line text , and provide empty space in middle for username.
i
f you want the user essentially puts something in there which you want to pass somewhere else and use it, then create an on submit client script to check whether the user has provided the value in that text field or not. You can also validate the provided value against whatever you want. If the user has not provided the value or the value doesn't matches per validation you can throw error message and restrict submission.
That is a easier way to go around it in working.
Please mark my answer as helpful if it helped you in anyway 🙂.