Calling Widget

t7
Tera Contributor

Hi Community, How can we call a widget inside a widget ?

4 ACCEPTED SOLUTIONS

Rahul Talreja
Mega Sage
Mega Sage

Hi @t7 ,
You can achieve this by concept of embedded widget.
Refer :Embedded widgets (servicenow.com)

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

View solution in original post

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello @t7 ,

                   You can refer below article to understand

How to communicate between widgets in Service Portal 

YouTube : Calling one Widget into another widget in ServiceNow 

 

Kindly mark correct and helpful if applicable

View solution in original post

Samaksh Wani
Giga Sage
Giga Sage

Hello @t7 

 

You can Embed the widgets in 3 ways :-

 

1. Embed with HTML template :-

 

 

<div>
    <widget id="widget-cool-clock"></widget>
</div>

 

 

2. Embed Widget with Client Script :-

 

 

function(spUtil) {
    var c = this;
    spUtil.get("widget-cool-clock").then(function(response) {
            c.myClockWidget = response;
    });
}

 

 

HTML :-   

 

<sp-widget widget="c.myClockWidget"></sp-widget>

 

 

3. Embed Widget with Server Script :-

 

 

(function() {
    var coolClockOptions = {"zone": "America/Los_Angeles","title": "San Diego, CA"}
    data.coolClockWidget = $sp.getWidget('widget-cool-clock', coolClockOptions);
})();

 

 

HTML :- 

 

<sp-widget widget="data.coolClockWidget"></sp-widget>

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

View solution in original post

4 REPLIES 4

Rahul Talreja
Mega Sage
Mega Sage

Hi @t7 ,
You can achieve this by concept of embedded widget.
Refer :Embedded widgets (servicenow.com)

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello @t7 ,

                   You can refer below article to understand

How to communicate between widgets in Service Portal 

YouTube : Calling one Widget into another widget in ServiceNow 

 

Kindly mark correct and helpful if applicable

Samaksh Wani
Giga Sage
Giga Sage

Hello @t7 

 

You can Embed the widgets in 3 ways :-

 

1. Embed with HTML template :-

 

 

<div>
    <widget id="widget-cool-clock"></widget>
</div>

 

 

2. Embed Widget with Client Script :-

 

 

function(spUtil) {
    var c = this;
    spUtil.get("widget-cool-clock").then(function(response) {
            c.myClockWidget = response;
    });
}

 

 

HTML :-   

 

<sp-widget widget="c.myClockWidget"></sp-widget>

 

 

3. Embed Widget with Server Script :-

 

 

(function() {
    var coolClockOptions = {"zone": "America/Los_Angeles","title": "San Diego, CA"}
    data.coolClockWidget = $sp.getWidget('widget-cool-clock', coolClockOptions);
})();

 

 

HTML :- 

 

<sp-widget widget="data.coolClockWidget"></sp-widget>

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh