logo

NJP

ServiceNow – Contextual Search

Import · Feb 01, 2023 · video

foreign today we're looking at contextual searches contextual searches that box that you usually see underneath a short description for many kinds of task records such as incidents and customer service cases and this box displays relevant search results from knowledge bases and catalog items to help us quickly resolve the task at hand so rather than having a related list that is updated when you see the record the contextual search results appear in real time so in this demonstration today we are going to add a contextual search box to a form in a custom table to display search results from a specific knowledge base okay so the custom table I've got here is this vehicle issue table this is just a simple form that I've got here it extends from the task table and I've got a few basic Fields here including the short description so what we want to do here is add the contextual search results just underneath the short description just like we do for the incident table for example so if I come down here you can see that the related search results here and this will display results from service catalog from knowledge bases based on the short description okay so our first Port of Call is a search context okay so let's go to contextual search here and we'll come down to search context this is kind of like the framework for our contextual search and we'll go ahead and create a new entry here and we'll just call this vehicle articles okay and articles related to uh vehicle faults okay and I'm going to leave everything else as the default but I'm going to specify a Searcher so this will actually determine what it is that we're actually searching as a catalog items or knowledge base articles or maybe something else but in contextual search and servicenow it's a little bit restricted because you can't actually add your own tables to be searched okay so if I just specify knowledge only here let me just save the record and we'll just take a look at that search a table so if we come across two searches here this is the table that is being referenced by that field you can see here we've got a variety of knowledge base and catalog searches and they're basically the two items that you can search you can't actually add your own custom tables here to be searched okay so you're a little bit restricted there so let's come back to our search context now the next thing we have to do is to specify where we want this contextual search box to appear it could appear in different locations record producers a form in a platform UI a form in workspace Etc so I'm going to come to table configurations and click new okay so the first thing we'll need to do is specify the table so I will select here the vehicle issue table okay the UI type it's going to be in the regular platform UI but you can also make it available in your workspaces other search context is there by default I've got a title related search results we could change that to something else such as um or related fault articles for example and I'll accept the default here as well active is true so in other words only active records will display the contextual search but you can change that filter and search as some of you may know this already have seen this before perhaps in a servicenow training class if you enable that you allowed you or allows the user to select another user to perform the search as so if you have user criteria for your knowledge based articles and catalog items then the search results that you get in the contextual search will be based on the user that is currently logged in that is using it and that may not necessarily be the same as the person who a task is recorded against so if you want to kind of ensure that the user that you want to send an article to or attach an article to a task record for uh it should have the right to view that article and then you can actually come here to search as and go okay I want to search as the person who is assigned to the task or the caller or someone else at the moment I don't have a caller because I don't have a caller in my vehicle issue table all right so I'll just leave that as it is and go ahead and save it okay so that should work just fine as it is without doing anything else okay we can see down here in related lists by default the short description for task records is used to search otherwise the search query for your articles or catalog items and but I'll just leave everything as is at the moment so if I come back to my form if I reload this page we won't actually see the contextual search box yet we have to make a change to the form itself so if I go to servicenow Studio here this is the current layout of the form so all I need to do is to scroll down to the bottom here and get my contextual search results formatter okay which is pre-configured in the platform so I'm just going to drag and drop that straight underneath short description and save it okay so we can go ahead and test this now if I come back to the form here and reload it okay we've got our related fault articles there okay now it's going to use the short description here as the query so if I open up that uh we've got a couple of Articles here all right but at the moment if I were to put in something else here I'm just going to put in email and tab we can see we've got articles here from different knowledge bases uh it and so forth okay so we're not actually restricted yet to a particular knowledge base it's searching every single knowledge base that I've got access to at the moment okay so what I will do to change that let's come back to our search context so I'll go back a page that's a table configuration and we'll open up the vehicle articles one that we created okay so to restrict you are able to first of all restrict access to a or the search to a particular knowledge base or knowledge basis or catalog or catalogs by going to the resource configurations tape here so this is entry here is populated automatically as soon as you put in a Searcher and save the record so if I open up the one here for knowledge what we need to do here is come to the condition and basically put an encoded query in here to say which knowledge base is we want to restrict the search to okay there is some documentation on this as well so what I'm going to do is just go ahead and copy this all right this is the sys ID of the vehicle faults knowledge base that I've already created so I'm just going to pop that in there okay so what I've done I've accidentally included some spaces here before and after the operator okay so I've removed those spaces I'm not sure if I saved it let's save it again and we'll come back and refresh this page and we should find now that those articles are back okay but they're from the vehicle false knowledge base that's okay but if we replace the short description with something like email and I press tab we get nothing because we're not searching any other knowledge base and there are no articles in my vehicle faults knowledge base that have anything to do with email okay let's go one step further now that we've restricted the search to a specific knowledge base let's say we had thousands of articles in that knowledge base and that was just kind of clogging up the search and we weren't really getting accurate search results is there a way in which we can perform some other filter on those records well yes there is we can restrict or filter those records according to essentially whatever we want so if we come back to our search resource let me just go back here to search contacts at start at the beginning and come down to beagle articles and this time instead of configuring the resource configurations where we can determine which knowledge base or catalogs we want to filter against or restrict the search to we can go to table configurations this time and open up that one that we created earlier and this time we can come down to filter configurations and specify a filter so let's go ahead and do that okay so the resource configuration will be based on knowledge articles that was one that we were using and if I come to the reference icon here you can see that it's only one possible one because that's the only one that's attached to our search context so we've got that now we need to script this you can actually do it an old school way if I actually save this what old school I mean just standard filter configuration here but I want to script it okay I want something a little bit more advanced than what is possible with that standard condition Builder there because I want to do a little bit of dot walking so I'm going to first of all save that now I've got here another line of code that I'm going to use okay so what we're going to do here we're going to restrict the query not only to that knowledge base but we're going to use the category of the articles that has to equal the the make of the vehicle so I'm actually not walking here to the vehicle table so let's do that and come back and I'm just going to put it straight underneath that add active query line pop it straight in there and that's all I need to do okay save it and now we can go ahead and test it all right so we can come back to our vehicle issues here now in order to test we'll need to understand what articles we have in the different categories so if I come back here to Volvo if I put in something like oil pressure here let's see if that is returned again I'll just refresh the page here again I'm not sure if it's necessary it shouldn't be but I always like to be on the safe side in case anything is cased that I'm not aware of so I'll put in here oil pressure tab we get that article excellent let's put a search query in here that is based on an article in another category such as engine stalls now involver we don't have anything related to that so let's put in engine oops let's get the typing going our engine stores tab nothing not because Volvo engines never store but because we restricted the search query to a particular category based on the make of the vehicle and if you look at the the vehicle it doesn't say Volvo in here but if you go to the preview here it is actually a Volvo make that we're dealing with here okay so that's it everyone that's how you add a contextual search box to your own custom table there's a few other things that we didn't go into different configuration but check the documentation uh there's a couple of things from memory uh such as when you want to restrict based on a catalog I don't think you need to specify the sysid I think just the name of the catalog suffices in the filter configuration and the the word that you want to base the search query on I think for task tables it's restricted to short description and a few other fields you can't just select any field but if a custom table is selected then you've got a little bit more freedom there um so yeah there you go um remember the the configuration itself is slightly restricted in terms of what table you can search so you are restricted to catalog items and knowledge base articles uh in general although for ins I think can also search for incidents and problem records and things like this there are also additional resources that you will find there that are being pre-configured so if you want to search for records and some other custom table you'll need to add that as related list to the form and populate that accordingly so thanks very much for watching everyone and see you next time [Music]

View original source

https://www.youtube.com/watch?v=-3EYZincE0s