Auto populate field in catalog item not visible

shaikkhasim
Tera Contributor

Hi Team

i am using Tokyo version, however Auto populate field is in catalog items not visible 

 

i have attached the image for that 

 

Regards

khasim

khasim
4 REPLIES 4

Samaksh Wani
Giga Sage
Giga Sage

Hello @shaikkhasim 

 

Plz find the link below :-

 

https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc....

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Danish Bhairag2
Tera Sage
Tera Sage

Hi @shaikkhasim ,

 

Auto populate tab is available from Utah version. As you are in Tokyo version it is not available. If you want to auto populate you can use GlideAjax or lookup select box type variable.

 

Thanks,

Danish

 

Hi @Danish

will you pls share the images , how can i Autopupulate the filed with the help of Glide Ajax or Look up select box

 

Regards

khasim

 

khasim

Hi @shaikkhasim ,

 

Here is the solution to this -

 

Create a new client callable script include with following function 

 

var UserDetails = Class.create();

UserDetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 

getUserInfo: function() {

var details = {};

var userId = this.getParameter('sysparm_user_id');

var userObj = new GlideRecord('sys_user');

userObj.addQuery('sys_id', userId);

userObj.query();

if (userObj.next()) {

details.email= userObj.email_id.toString();

}

return JSON.stringify(details);

},

 

type: 'UserDetails'

 

});

 

 

 

Create a new catalog client script on the record producer/request form

 

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {

return;

}

 

var ajax = new GlideAjax('UserDetails');

ajax.addParam('sysparm_name', 'getUserInfo');

ajax.addParam('sysparm_user_id', g_form.getValue('employee_name')); // change variable name here

ajax.getXML(doSomething);

 

function doSomething(response) {

var answer = response.responseXML.documentElement.getAttribute("answer");

var answers = JSON.parse(answer);

g_form.setValue('var_email_id', answers.email.toString()); // change variable name here

}

}

 

Thanks,

Danish