- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:25 AM
Hello,
I have a request to create a pop up alert with a clickable hyperlink, but I am struggling to do this. I haven't found much on this. What I need is an onChange() Catalog Client Script that will display an alert() that has a clickable link.
We have used the g_form.addInfoMessage(), but the business does not want this, they want it through the form of a pop-up. We are trying not to achieve this with a modal but using the alert().
Does anyone have any idea how to do this?
If this cannot be done through the alert(), how can I do this with the use of a modal?
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 11:26 AM
Update the client script to send the value as a window property using setPreference to the UI page. I'm sending an hardcoded value for testing but please replace it with whatever value you like to send.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dialog = new GlideDialogWindow("open_google"); //Render the dialog containing the UI Page 'task_comments_dialog'
dialog.setTitle("POPUP WITH HYPER LINK"); //Set the dialog title
dialog.setPreference('id', '12'); // Replace '12' with your dynamic value.
//dialog.setPreference('id', 'ABC');
dialog.render(); //Open the dialog
}
Recieve that on the page and as you have multiple values to choose from so you can use choose tag of jelly script to do this.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var someText = RP.getWindowProperties().get('id'); // Receiving the value from Client script via GliadeDialogWindow
</g:evaluate>
<j:choose>
<j:when test="${someText.equals('12')}"><a href='https://www.google.com'>Google</a></j:when>
<j:when test="${someText.equals('XYZ') }"><a href='https://www.google.com'>Youtube</a></j:when>
<j:otherwise>Sorry, we could not find the record you specified.</j:otherwise>
</j:choose>
</j:jelly>
Hope that helps!
Helpful and Correct tags are highly appreciated!
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 11:22 PM
Hi,
If my response helped please mark it correct and close the thread so that others get benefit in future.
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar