Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Embedded Service Portal Widget fails to pass options data in Xanadu

Amahle
Tera Contributor

Environment:
ServiceNow Release: Xanadu Patch 3
Interface: Service Portal (/sp)
Browser: Google Chrome (Latest)

Summary:
When embedding a custom child widget inside a parent widget using $sp.getWidget(), the options object passed from the parent server script is received as undefined or empty in the child widget's server script.

Expected Behavior:
The child widget should receive the configuration properties passed into it, allowing it to dynamically query data based on the parent widget's context.

Actual Behavior:
The child widget loads its default template state because options.table returns undefined when logged on the child server-side script. No console errors are thrown, but the data binding fails silently.

Steps to Reproduce:
1. Create a parent widget that calls a child widget.
2. Pass an options object via the server script using: data.childWidget = $sp.getWidget('child-id', {table: 'incident'});
3. Render it in the HTML using <sp-widget widget="data.childWidget"></sp-widget>
4. Add gs.addInfoMessage(options.table) inside the child widget's server script. It returns undefined.

Parent Server Script:
(function() {
var widgetOptions = {
table: 'sn_customerservice_case',
limit: 5
};
data.childWidget = $sp.getWidget('my_custom_child_list', widgetOptions);
})();

**Child Server Script:**
(function() {
// ISSUE: options is empty here
gs.addInfoMessage("Passed table is: " + options.table); // Returns: "Passed table is: undefined"

if (!options.table) return;
// ... rest of logic
})();

0 REPLIES 0