Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add multiple widgets in single widget?

Prabhakar9
Tera Contributor

Hi Team,

I am not able to add multiple widgets in a single widget while creating the dashboard. Could you please help me out.

Thanks & Regards,

Prabhakar

15 REPLIES 15

NeuraalLabs
Tera Contributor

As documented here: https://docs.servicenow.com/en-US/bundle/sandiego-servicenow-platform/page/build/service-portal/concept/c_NestedWidgets.html

Server Script:

    var options = [
        {zone: "America/Los_Angeles", title: "San Diego"},
        {zone: "America/Denver", title: "Denver"},
        {zone: "America/Chicago", title: "Chicago"},
        {zone: "America/New_York", title: "New York"}
    ];

    data.clocks = [];
    for (var i in options) {
        data.clocks.push($sp.getWidget("widget-cool-clock", options[i]));
    }

HTML:

<div ng-repeat="myClock in c.data.clocks">
        <sp-widget widget="myClock"></sp-widget>
      </div>

 

Be sure to add option schema to the widget you want to have multiples of, so you can feed it unique data.