Autocomplete suggestion on service requests

Carlo1
Tera Contributor

Hi Al,

I would like to know if anyone has implemented 'autocomplete' with suggestions based on the historical inputs of a Requestor.

 

We currently have a service catalog that will ask the Requestors for the Product Name, Transaction Type, and Application Type.  After that, the next questions would be to ask for Customer's Name, Customer's Email Address, and Customer's Contact Number, and the details of the customer's request.  

 

Same as the functionalities on the browser, is there a way to autocomplete the form based on previous requests of the Requestors?  

 

 

 

 

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Carlo1 ,

 

The information from browser comes from the cache where whatever user has types of searches gets stored in it n when the next time user starts typing it displays the relevant results.

 

But in servicenow that feature is not available. But it does have Reference fields where it gets value from a particular table. Fo eg name u can create a reference field n map the user table to that and then whenever user starts typing it will give them suggestions based upon the values present in the reference table.

 

Thanks,

Danish

Vaibhav_Nikam
Tera Guru

Hi @Carlo1 
For the auto-population, you can refer below scripts:

 

1. Script Include (must be client call-callable):

getDetail: function() {

var sysId = this.getParameter('sysparm_id');

var getRitmRecord = new GlideRecord('sc_req_item');
getRitmRecord.addEncodedQuery('request='+sysId^'requested_for'+cur_user);
getRitmRecord.query();
var cur_user = gs.getUserID();
if (getRitmRecord.next()) {
//You can copy the fields required for the autocomplete here
//for reference i have tried for an email address in the below line
 
var itemName = getRitmRecord.requested_for.email();
gs.info('line number 14' + itemName);
}
return itemName;
},
 
 
2.client script:
var sysId = g_form.getUniqueValue();
alert(sysId);

var gr = new GlideAjax('getShortDescription');
gr.addParam('sysparm_name','getDetail');
gr.addParam('sysparm_id', sysId);
gr.getXML(getResponse);
}
function getResponse(response){
var ans = response.responseXML.documentElement.getAttribute('answer');
// alert(ans);
g_form.setValue('email',ans);
//g_form.setValue('description','Testing Description');
}

If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.

Thanks,

Vaibhav Nikam

Thanks for this! I will try this script,  and update this forum.