widgetreportservicenow

How to use OOB report widget as embedded servicenow


For simple listing OOB (out of the box) widget, I can able to write code like this:

HTML:

<widget id="widget-simple-list" options="data.approvalsOption" ></widget>

Server script:

    data.approvalsOption = {
        "secondary_fields":"u_incident_title",
        "always_show":"true",
        "table":"incident",
        "filter":"",
        "display_field":"number",
        "maximum_entries":"5"
    };

In a similar way, I want to add an embedded report widget, I tried something like this:

HTML inside another widget:

<widget id="report" options="data.reportData" ></widget>

Server script:

data.reportData = {
    "report_id":"45ytrhg43trgfgerewrfdads"  //My report sys_id
};

I am able to achieve this with page designer and Edit->select_report (but I want as the embedded widget)


Solution

  • Try this:

    HTML inside another widget:

    <sp-widget widget="c.data.embeddedReport"></sp-widget>

    Server Script

        var reportOptions = {
            report_id: "45ytrhg43trgfgerewrfdads",  // Report sys_id
            widget_parameters: '{"report_id":{"displayValue":"Report Title" }}'
        };
        
    data.embeddedReport = $sp.getWidget("report", reportOptions);