Service Portal - Icon Link to external URL with additional information

ljg
Kilo Contributor

Hi,

We currently have a content management portal and are moving to service portal.  We currently have a link from a content block to an external URL but we also pass specific information on open so that the external site knows what user 'welcome' (from the user ID), and that it opens in an optimum sized window.

ie:

        window.open("https://<website address>/?un=${gs.getUserName()}", 'popup',   
        'location=no,toolbar=no,menubar=no,scrollbars=yes,width=760,height=600');

Can someone please let me know how we can do this with an icon link widget? (Or any other widget as long as I can get it looking roughly the same as an Icon link)   At the moment we have the target specified in the widget instance as _blank to open in a new tab:

{
   "target": {

     "value":"_blank"

   },
    "link_template": {
        "value": "Circle Icon",
        "displayValue": "Circle Icon"
    }
}

thanks in advance.

1 ACCEPTED SOLUTION

davmar
ServiceNow Employee
ServiceNow Employee

Hi,

a simply way on how you can achieve this, shwon in the image attached bellow:

 

find_real_file.png

 

Hope it helps.

View solution in original post

4 REPLIES 4

Pankaj Bisht1
Giga Guru

Hello,

 

Instead of using window.open , use location.href = "your url" . Refer to below code for reference and usage . Now here you can parse the data using &data1=123&data2=345 etc

 

function check()

{

   

    var url = new URL(location.href);

    var c = url.searchParams.get("sysparm_sys_id");

     var strconfirm = confirm("Do you want to redirect ?");

     if (strconfirm == true) {

        location.href="/incident.do?sys_id="+c;

    }

    else{

    return false;

    }

}

 

Hi,

Thank you - so sorry to ask what may seem a dumb question, but where would that script go?

in the Icon link we have the Type set to URL and our URL is in the URL field and then we have the "target" specified in the widget instance under the Presentation/Additional options, JSON format field, so where would the script you mention need to go and do we need to change anything else?  Thank you 🙂

find_real_file.png

At the moment we have the target specified in the widget instance as _blank to open in a new tab:

{
   "target": {

     "value":"_blank"

   },
    "link_template": {
        "value": "Circle Icon",
        "displayValue": "Circle Icon"
    }
}

 

davmar
ServiceNow Employee
ServiceNow Employee

Hi,

a simply way on how you can achieve this, shwon in the image attached bellow:

 

find_real_file.png

 

Hope it helps.

ljg
Kilo Contributor

Thank you so much!  You're a star - it works a treat!