- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 01:37 PM
Hi,
Looking for some assistance please. I am hoping I can explain what I am looking for as best as I can 🙂
I have a cat item with a number of variables on it:
First Name (first_name)
Last Name (last_name)
Email Address (email_address)
Finally I have a HTML variable called Preview (preview).
I am able to create an onChange Catalog Script that will do the following:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
function populateHTML() {
var fullName = g_form.getValue('full_name');
g_form.setValue('preview', fullName);
}
populateHTML();
}
Now this works ok however, this is what I am really looking for can I put something into the HTML variable that the form field (First Name) can reference to place the information to?
So person types First Name on the form > which will then look at the HTML variable and reference a variable inside the HTML variable (such as fname) and populate the information accordingly.
This sounds a lot simpler to explain in my head than on paper so I really do hope someone can help me.
Thanks
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:20 PM
Hi Dan. I updated your other post with something that should work: https://community.servicenow.com/community?id=community_question&sys_id=4d991a88dbc64d90ae8125091396...
It's basic but does the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:42 PM
That is possible, of course. Just have to concatenate (or interpose) text with (into) HTML code; e.g:
g_form.setValue('html', '<p>' + g_form.getValue('name') + '</p><p style="text-align: right;">' + g_form.getValue('surname') + '</p>');
Of course making sure that the values interposed or added are properly HTML escaped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:20 PM
Hi Dan. I updated your other post with something that should work: https://community.servicenow.com/community?id=community_question&sys_id=4d991a88dbc64d90ae8125091396...
It's basic but does the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 03:25 PM
Thank you Wayne, taking a look now.