How to set embedded widget options via clint script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 02:55 AM
How can we set embedded widget options via client script
HTML Templates
<div class="form-group">
<p>
Embedded widget via Client Script
</p>
<sp-widget widget="c.clientScriptWidget"></sp-widget>
</div>
Client Script
function(spUtil){
spUtil.get('widget-cool-clock').then(function(response){
c.clientScriptWidget=response;
});
}
function(spUtil){
spUtil.get('widget-cool-clock',{c_color:"orange"}).then(function(response){ //not working
c.clientScriptWidget=response;
});
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 12:18 PM
This works for widget-cool-clock where the options are c_color. How can this be adapted where embedded widget is a simple-list-widget and the options to be added are 'table='incident'' ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 05:17 AM
thank you very much

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 05:48 AM
If anybody still didnt find solutions for this, you can try below.
create a rootscope variable in the main widget client controller:
api.controller = function($scope, $rootScope) {
$rootScope.variable_name = "Some Value";
spUtil.get("embedded_widget_id").then(function(response) {
$scope.embedded_widget = response;
});
}
Add the ng-template to the HTML of main widget, you can also create new ng-template record as well:
<script type="text/ng-template" id="embedded_widget_template">
<sp-widget widget="embedded_widget"></sp-widget>
</script>
Now call the widget without any options and within the embedded widgets client controller you can access the variable value as below:
spUtil.addInfoMessage($rootScope.variable_name);