Cannot find function getWidgetFromInstance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2016 08:01 AM
I'm trying to create a new header widget for use in a new service portal and I keep getting an error about the "getWidgetFromInstance" function when I try to fetch my menu.
js_includes_sp.jsx?v=05-16-2016_1044&lp=Tue_May_24_10_45_09_PDT_2016&c=2_42:71072 Server JavaScript error Cannot find function getWidgetFromInstance in object com.glide.service_portal.widget.fencing.ScopedSPScriptable@1044129.
Here is the server side code.
data.login_page = $sp.getValue('login_page');
var menu = $sp.getValue("sp_rectangle_menu");
data.menu = $sp.getWidgetFromInstance(menu);
It is the same first three lines that are in the stock header widget, so I have no idea why it can't find the function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2016 10:11 PM
Are you working in a application scope? There are several $sp methods that do not work when they are not in Global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2016 12:13 AM
What does that "getWidgetFromInstance" method even do? How does it know to use the menu widget to build the actual menu? Is there any documentation on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2016 01:43 PM
The getWidgetFromInstance method generates the object needed to embed a widget in another widget. So for example I have an "instance" that defines some slides for the carousel widget, I can then call getWidgetFromInstance and pass in that instance which will return an object which can be used with the <sp-widget> directive to place that carousel and slides inside the parent widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2016 04:35 PM
How does "getWidgetFromInstance" know it's a "menu widget" when all you're passing is a sys ID. How does it know to use a specific widget to build from that ID? Does this mean that there's logic conditions within the "getWidgetFromInstance" which determines if the pass ID is from "menus". And if that is the case, how do you pass the menu id of the portal and tell it to use another menu widget, as it seems to automatically use the "Header Menu" widget and because of it's limitations, i.e no class, id or 'active' events/classes on menu items, I have to build my own menu system.
[Model]
var menu_sys_id = $sp.getValue("sp_rectangle_menu");
// load menu into page
data.menu = $sp.getWidgetFromInstance(menu_sys_id);
[View]
<sp-widget widget="data.menu"></sp-widget>
So my question to sum up, where does it state to use the "header menu" widget and how does one change it to use a different menu widget?