Why am I getting 'No Preview available'?

Sana10
Kilo Contributor

Hi Community,

 

Reference Icon not showing preview

We have a requirement where we need to populate other fields with the correct data when clicking on selected location.For this I have written
script include and on change client script, It is working fine I can populate the data in the field.We have a List, Edit, Disable ACL on this field.
Problem is whenever this variable is getting auto populated it is not showing preview on refrence icon.

Please help me to sort out this. since I have to deploy this as soon as possible.

find_real_file.png

Thanks.

11 REPLIES 11

Varsha21
Giga Guru

Hi Sana,

 

Please try to initialize sys_id to suit/area field.,it may give proper result.

 

else please share your client script code here,so cab be help you.

 

Regards

Varsha

Community Alums
Not applicable

Hi Varsha,

sys_id is also showing no preview avaliable. Here is the code.

checkType(gr.u_type,gr.name.toString());
var par=gr.parent;
gs.addInfoMessage(par.u_type);
while(par.u_type!='')
{
gs.addInfoMessage(par.u_type);
checkType(par.u_type,par.name.toString());
par=par.parent;
}

 

Thanks.

Hi sana,

please share your Onchange client script also and script include,because from provided script i am not getting clear idea where exactly you are populating value on form field.

 

Thanks 

Sana10
Kilo Contributor

Hi Varsha,

sure. Below is the script.

 

Client script: on change of location

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax("GetLocationDetails");
ga.addParam("sysparm_name",'locDet');
ga.addParam("sysparm_loc_det",g_form.getValue("location"));
ga.getXML(testLoc);

function testLoc(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
var returneddata = JSON.parse(answer);
//alert('test'+returneddata.street);

g_form.setValue('u_facility',returneddata.u_facility);
g_form.setValue('u_building',returneddata.u_building);
g_form.setValue('u_location_floor',returneddata.u_location_floor);
g_form.setValue('u_suite_room_cube',returneddata.u_suite_room_cube);
g_form.setValue('u_room_cube',returneddata.u_room_name);
}
g_form.setReadOnly('u_facility',true);
g_form.setReadOnly('u_building',true);
g_form.setReadOnly('u_location_floor',true);
g_form.setReadOnly('u_suite_room_cube',true);
g_form.setReadOnly('u_room_cube',true);

}

Script Include:

var GetLocationDetails = Class.create();
GetLocationDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
locDet: function(){

var arr = {};
var loc = this.getParameter("sysparm_loc_det");
var gr = new GlideRecord("cmn_location");
gr.addQuery("sys_id",loc);
gr .query();

var obj={};
if(gr.next()){

obj.u_room_name ='';//14
obj.u_suite_room_cube ='';//13
obj.u_location_floor ='';//6
obj.u_building ='';//5
obj.u_facility =''; //4

checkType(gr.u_type,gr.name.toString());
var par=gr.parent;
gs.addInfoMessage(par.u_type);
while(par.u_type!='')
{
gs.addInfoMessage(par.u_type);
checkType(par.u_type,par.name.toString());
par=par.parent;
}}
function checkType(u_type,value)
{
if(u_type==4)
{
obj.u_facility=value;
}
else if(u_type==5)
{
obj.u_building=value;
}
else if(u_type==6)
{
obj.u_location_floor=value;
}
else if(u_type==13)
{
obj.u_suite_room_cube=value;
}
else if(u_type==14)
{
obj.u_room_name=value;
}
}
var data = new JSON().encode(obj);
return data;
},

type:'GetLocationDetails'

});

 

Thanks