Need to call widget from another widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 12:08 AM
Hi,
I am trying to get the widget from another widget. I have tried using the below code, but it is getting as empty only. "sc-variable-summarizer" this is OOB so i dont want to disturb this code.
HTML:
<div>
<div>
<sp-widget widget="data.details_widget"></sp-widget>
</div>
</div>
Server script:
data.details_widget = $sp.getWidget("sc-variable-summarizer", {
sysId: taskGr.sys_id,
tableName: getTaskRecord()
});
I can see that widget is getting called but the variables are not coming for the current record. I called the widget widget is in green color.
Please help me on this. Thanks in Advance.
Thanks and Regards,
Allu Gopal.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 06:50 AM
Did you check if "sc-variable-summarizer" widget needs initial inputs to show data? which is normally sent as options object as example shown below.
options.source_table="sc_2_kb";
options.target_column="kb_knowledge";
options.source_column="sc_cat_item";
options.always_show=false;
data.template = $sp.getWidget("kb_related_articles",options);
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 06:58 AM
Hi Abhijit,
Thanks for reply, you mean this var tabname= options.table it will fetch dynamically.
Thanks and Regards,
Allu Gopal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 04:06 AM
Hi,
If you look at below image which is from Variable Summarizer widget, this widget is trying to get data from Options object.
This inputs are configured in widget options schema for individual widget instance. When you configure any widget via UI then it has some values which are being used in script via options object. But in your case since you are calling widget via script, those values will be empty so you will have to pass appropriate value for each variable while calling widget with above provided scripting method.
To check which variables are used as input, you can use Ctl+Right Click -> Widget Options Schema as shown below
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP