Service Portal - Embedded widgets and passing in options

Vegard S
Kilo Sage

I'm trying to avoid tech debt by embedding OOTB widgets within my own custom widget and pass my widget options into the embedded widget options data. 

This mostly works, however, I'm having some trouble with embedding the topic_content widget. 
All I need to do is expand the options.limit so I can have the limit set to 6 instead of 12 or 24.

It works great initially, but when I change the Filter by it resets to 12. 
This does not happen when I just use the ootb widget without embedding and change the instance option to 6 manually. The limit stays at 6 as intended. 

I figure there's something going on with how the data is passed but I can't figure out why this happens.

My HTML looks like this:

<div>
<sp-widget widget="data.widget"></sp-widget>
</div>


Server script looks like this: 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	data.widget = $sp.getWidget('topic_content', options);
})();


I'm interested in finding out why this happens.

Changing the filter triggers getUpdatedContent() from the client script of the topic_content widget.
And it refreshes the data and in turn runs updateContent() which contains all the server inputs, including limit which is tied to c.data.limit.

So it's almost as if c.data.limit gets reset and doesn't use the options.limit that I initially sent in. 

1 REPLY 1

Manoj56
Tera Contributor

Server Script

 

var v_rel_options ='{limit: 8,title:mj widget,category:knowledge and catalog,list_type:Card List,card_behaviour:wrap,load_config:async}';

data.relevant_for_you = $sp.getWidget("relevant_for_you", options = v_rel_options);

 

HTML

 

 <sp-widget widget="data.relevant_for_you"></sp-widget>​