Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How can I add a search bar within my SP widget?

Bushra Syed
Tera Contributor

I have a service portal widget that is a sidebar for my custom Service Portal and I want to add a typeahead search into it. Currently, I have code like this:
HTML:

 

 

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

 

 

 

SERVER:

 

 

 data.example = $sp.getWidget('typeahead_search', {});

 

 

This doesn't work 

 

"$sp is not defined".  

Is there any way to do this?

3 REPLIES 3

Dr Atul G- LNG
Tera Patron

Hi @Bushra Syed 

 

Please provide screen shot where you want to add?

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

It is within a custom widget I made. 

ChrisBurks
Giga Sage

Hi @Bushra Syed ,

If you're using a portal widget your code should be good the way it is except for the widget id for the typeahead search. The id for that widget has a hyphen and not an underscore.

Using the widget editor with preview on, the screenshoot below shows the code working.

portal_widget_with_embedded_search.png