- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 02:25 AM
Hi,
So the requirement is that when an incident changes priority to critical, a warning message comes up and it needs to have a clickable link which leads to a knowledge article. I have made a client script for this but not sure how I can add the url to the Knowledge article. What am I doing wrong here? If I remove the var url alltogether than everything works fine. If I add it before the if statement it still does not work.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 1) {
var url = <a href = "https://lbg.service-now.com/it_lbg?id=kb_article&sysparm_article=KB0078495"> KB0078495 - critical incident guidance </a>
var res = confirm("Warning! Creating an incident with critical priority will automatically start the major incident process. Truly critical incidents are extremely rare so please ensure you fully understand the implications before submitting an incident with that priority. See" + url);
if (res == true) {
return true;
} else {
//g_form.setValue('priority',oldValue);
g_form.setValue('impact', g_scratchpad.impact);
g_form.setValue('urgency', g_scratchpad.urgency);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 08:31 AM - edited ‎10-18-2023 08:55 AM
Hi,
Hello, we have some problems using & because the code understands that you will write some Unicode like < and unfortunately, we couldn't get around it.
To redirect to an article you can use the link '/kb_view.do?sys_kb_id=c85cd2519f77230088aebde8132e70c2'
It will redirect on the platform and not on the portal
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == '1') {
var text = "Warning! Creating an incident with critical priority will automatically start the major incident process. Truly critical incidents are extremely rare so please ensure you fully understand the implications before submitting an incident with that priority. See   <a href='/kb_view.do?kb_article=KB99999999 ' target='_blank' > KB99999999 - Microsoft Outlook Issues </a>";
var gm = new GlideModal ("glide_confirm_basic", true, 600);
gm.setTitle("Test title");
gm.setPreference("title", text);
/* gm.setPreference("onPromptComplete", function() {
alert("You clicked on 'Ok'")
});*/
gm.setPreference("onPromptCancel", function() {
//alert("You clicked on 'Ok'")
g_form.setValue('impact', g_scratchpad.impact);
g_form.setValue('urgency', g_scratchpad.urgency);
});
gm.render();
};
}
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 02:34 AM
You can't put URL in browser confirm. Instead you can use UI page for this. Create a UI page and call via GlideModal.
Please mark my answer as correct and helpful if it solves your issue
Thanks,
Phanindra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 07:14 PM - edited ‎10-17-2023 07:22 PM
Hi @snow_beginner and @psphanindrakuma
The best way to achieve your goal would be using the modal glide, here is an example of code that you can use.
Note that I needed to replace the & with %26 and the space with  
function onLoad() {
//Type appropriate comment here, and begin script below
var text = "Warning! Creating an incident with critical priority will automatically start the major incident process. Truly critical incidents are extremely rare so please ensure you fully understand the implications before submitting an incident with that priority. See   <a href='https://lbg.service-now.com/it_lbg?id=kb_article%26sysparm_article=KB0078495' target='_blank' > KB0078495 - critical incident guidance </a>";
var gm = new GlideModal("glide_confirm_basic", true, 600);
gm.setTitle("Do you want to create a major incident?");
gm.setPreference("title", text);
gm.setPreference("onPromptComplete", function() {
g_form.save()//Save Record
});
gm.setPreference("onPromptCancel", function() {
g_form.setValue('impact', g_scratchpad.impact);
g_form.setValue('urgency', g_scratchpad.urgency);
});
gm.render();
}
Note that I didn't need to create a customized UI Page to achieve the objective following good practices using ootb
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 06:19 AM
Hi, thanks so much for helping with this.
But this is an onLoad client script, so the warning comes up on loading the incident page. I changed it to an onChange client script and that's working but with an issue.
As soon as I change the 'Impact' OR 'Urgency' field, the warning comes up. It should come up when both of these values change to high so that priority changes to Critical. How can that be fixed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2023 06:31 AM - edited ‎10-18-2023 06:31 AM
Hi,
I made some changes to the code to get the result you want.
We could create two onChange Client Scripts for the urgency and impact fields, however, we can use the priority field, as the priority will be 1- Critical if the impact and urgency are high.
So just add a client script on change in the priority field and we can get the expected result
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == '1') {
var text = "Warning! Creating an incident with critical priority will automatically start the major incident process. Truly critical incidents are extremely rare so please ensure you fully understand the implications before submitting an incident with that priority. See   <a href='https://lbg.service-now.com/it_lbg?id=kb_article%26sysparm_article=KB0078495' target='_blank' > KB0078495 - critical incident guidance </a>";
var gm = new GlideModal("glide_confirm_basic", true, 600);
gm.setTitle("Test title");
gm.setPreference("title", text);
/* gm.setPreference("onPromptComplete", function() {
alert("You clicked on 'Ok'")
});*/
gm.setPreference("onPromptCancel", function() {
//alert("You clicked on 'Ok'")
g_form.setValue('impact', g_scratchpad.impact);
g_form.setValue('urgency', g_scratchpad.urgency);
});
gm.render();
};
}
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People