What is the syntax for string templates in scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 02:29 PM
Hi All,
Really simple question that I can't seem tot find the answer to.
I have a templated string stored in the message table "Hello {0}, you have completed the form...."
I want to retrieved this string
and then present the message to the user with
gs.addinfomessage(message.format("Jeff");
I would have expected this to show the message "Hello Jeff, you have completed the form..." but the result is undefined.
testing in a background
var message = "Hello {0}, you have completed the form....";
gs.info(message.format("Jeff"));
result: undefined.
is String.format() not a function that works in ServiceNow, what is the alternative?
I have seen Virtual agent use this, but I can't get to the underlying code to see the syntax.
Thank You in advance.
-Jeff
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 05:25 PM
Hi Jeff,
There is a script include RecordToHTML you can create something similar to it.
Please refer this thread. https://community.servicenow.com/community?id=community_question&sys_id=8236d65edbe86f8067a72926ca96...
Hope this will be helpful and correct. if this helped you in someway.
Please mark the answer as helpful and correct.
Best Regards,
Rajat Choudhary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 06:51 AM
The is sort of what I'm looking for but not quite. The source code does shed some light on a possible implementation.
I think there is no OOB way of doing this and one would have to write there own method for this functionality. I have seen Virtual agent use this feature, so I wish I could just see the source code for the vaSystem to see how it was implemented.
Thanks.