How to add a link in a warning message?

snow_beginner
Mega Guru

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);

           }
       }
   }

 

1 ACCEPTED SOLUTION

Hi,

Hello, we have some problems using & because the code understands that you will write some Unicode like &lt; 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 &#160; <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();
    };

}

 

 

Vanderlei_0-1697643078140.pngVanderlei_1-1697643096094.png

If my answer helped you, please mark my answer as helpful.

 

Vanderlei Catione Junior | LinkedIn

Senior ServicePortal Developer / TechLead at The Cloud People

View solution in original post

7 REPLIES 7

Thanks, that has worked! Just one final thing. The link to the article does not actually open the article. It gives an error and I think its because you changed & to %26 in the link before the sys_parm. Why did you do that? 

 

When I changed it back to & in the link then when I try to set the incident to critical, I get a pop up errorCapture.PNG

Hi,

Hello, we have some problems using & because the code understands that you will write some Unicode like &lt; 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 &#160; <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();
    };

}

 

 

Vanderlei_0-1697643078140.pngVanderlei_1-1697643096094.png

If my answer helped you, please mark my answer as helpful.

 

Vanderlei Catione Junior | LinkedIn

Senior ServicePortal Developer / TechLead at The Cloud People

Thanks so much for all your help!