How to pass options to embedded widget

Feddy
Kilo Sage

 

Hi All,

We have cloned OOB "Typeahead" widget and using it has embedded widget in homepage widget.
Also , it is embedded to "Faceted Search" widget in "search" page. 

Below is the client controller part I would like set from parent widgets, 

Client controller component of custom typeahead widget

var newUrlObj = {
                    id: 'search',
                    spa: '1',
                    q: payload.searchTerm,
                    disableAllSuggestions: c.options.disable_all_suggestions && c.options.disable_all_suggestions.toString(),
                    search_application: c.options.search_application || undefined,
                    search_results_configuration: c.options.search_results_configuration || undefined,
                    searchFilters : $location.search().searchFilters || c.data.aiSearchSourceFilter || undefined,

// I would like to set the above values empty if the widget is called from homepage widget


                    disableSpellCheck: 'false'
                };




Server script component of parent widget

var aisEnabled = $sp.isAISearchEnabled();

if (aisEnabled) {
    data.typeAheadSearch = $sp.getWidget('custom_typeahead_search_v1', options);
    options.title = gs.getMessage(options.title);
    options.short_description = gs.getMessage(options.short_description);
    options.search_results_configuration='';  // I would like to send this to typeahead widget
} else {
    data.typeAheadSearch = $sp.getWidget('custom_typeahead_search_v1', options.typeahead_search);
    options.title = gs.getMessage(options.title);
    options.short_description = gs.getMessage(options.short_description);
    options.search_results_configuration='';
}

 

 

The issue we are facing is that whenever we search from homepage widget , it is setting some search application/filter because of our customization and it is not landing on All tab in faceted search widget.


Any input on this would be much appreciated.

Thanks,
Fedrick

2 REPLIES 2

Martin Ivanov
Giga Sage
Giga Sage

Hi. Please refer to this article for passing data from one widget to the other.

Please mark Correct and Helpful if my answer helps you resolve your issue. Thanks!
Martin Ivanov
Community Rising Star 2022


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Martin Ivanov
Giga Sage
Giga Sage

Hi. If my answer has helped you resolve your issue, Please mark Correct and Helpful. This way, other users may also benefit from the thread. Thanks!
Martin Ivanov
Community Rising Star 2022


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024