Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Embedded Widget Option Not Working

JayGervais
Kilo Sage

Hi there,

 

I am trying to embed the typeahead-search widget into a custom widget with the title option updated so the default text on the search box can be changed. I have tried numerous methods in both client and server scripts to update this and can't seem to make it work.

 

This is my current code:

HTML:

 

<div id="cssd-department-header">
  <div class="col-md-8">
    <h1 class="cssd-dept-label">{{c.options.department}}</h1>
  </div>
  <div class="col-md-4">
    <div class="cssd-search-box">
      <sp-widget widget="data.typeAheadWidget"></sp-widget>
    </div>
</div>

 

Client script (the option here is left from another attempt):

 

function(spUtil) {
  /* widget controller */
  var c = this;
	
	spUtil.get('typeahead-search').then(function(response){  
			response.options.title = "Search ASK";
			c.typeAheadWidget = response;
	});
};

 

Server Script:

 

(function() {
	
	var typeAheadOptions = {
		// "title": {"value": "Search ASK","displayValue": "Search ASK"}
		"title": "Search ASK"
	}
  data.typeAheadWidget = $sp.getWidget('typeahead-search', typeAheadOptions);
	
})();

 

Any idea what I am doing wrong?

Thanks!

2 REPLIES 2

Ahmmed Ali
Giga Sage
Giga Sage

Can you try below code:

 

Client:

function(spUtil) {
  /* widget controller */
  var c = this;
	
	spUtil.get('typeahead-search', {title: "Search ASK"}).then(function(response){  
			//response.options.title = "Search ASK";
			c.typeAheadWidget1 = response;
	});
};

 

HTML:

<div id="cssd-department-header">
  <div class="col-md-8">
    <h1 class="cssd-dept-label">{{c.options.department}}</h1>
  </div>
  <div class="col-md-4">
    <div class="cssd-search-box">
      <sp-widget widget="c.typeAheadWidget1"></sp-widget>
    </div>
</div>
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Kaju
Tera Contributor

Hello ,

This issue is sorted?

Facing same issue.