Dynamically update variable instructions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2016 08:45 AM
Hi All,
Is there a way to dynamically update catalog variable instructions in a service portal.
I've created a variable set that includes a manager variable, and for 80% of my items it will have the instruction "Line manger of user"
However for the other 20% the text should read "Authorising manager".
I know I could create the variables for each item but I was hoping for a more elegant solution.
Thanks
William
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 06:29 AM
@W Fortune1 Did you find an answer in the last 7 years? : )

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 08:01 AM
Yes, there is a way. Here it is:
function onLoad() {
var myField = g_form.getField("u_sd_location"); //getField works in portal only, not Platform UI.
var myInstructions =
"My Happy Instruction Text. " + "For more help, please read the [AnchorTag]";
//Build a URL that includes the URI of the Current Instance (dev, test, prod), and also a link to the Portal knowledge article.
var fullURL = "[instanceURI][pagePath][article_id]";
//var instanceURI = gs.getProperty('glide.servlet.uri'); //Works in Server-Side code only, not client-side Catalog Client Script code.
var instanceURI = this.location.origin;
var pagePath = "/kb_view.do?sysparm_article=";
var kbNumber = "KB0010981";
var anchorText = "Knowledge Article";
fullURL = fullURL.replace("[instanceURI]", instanceURI);
fullURL = fullURL.replace("[pagePath]", pagePath);
fullURL = fullURL.replace("[article_id]", kbNumber);
//Now wrap that URI in an HTML Anchor tag.
var anchorTag = '<a href="[fullURL]" target="_blank">[anchorText]</a>';
anchorTag = anchorTag.replace("[fullURL]", fullURL);
anchorTag = anchorTag.replace("[anchorText]", anchorText);
myInstructions = myInstructions.replace("[AnchorTag]", anchorTag);
myField.instructions = myInstructions;
}