No Preview available for a varaible of type reference field on request item?

sonalin
Tera Expert

find_real_file.png

 

This is a form where we have to get data name of a Computer[cmdb_ci_computer] table. I have written a catalog client script which manges to give the exact value of the Computer Name assigned to the User[sys_user]. However I am unable to get the Preview of the Data. Due to this I cannot see this value in the Requested Item as below:

find_real_file.png

 

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

Appreciate all the help. Thank You.

 

1 ACCEPTED SOLUTION

Hi Sonali,

 

Try using below snippet.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var empcidetails = g_form.getReference('select_user',setci);
alert('User is '+empcidetails);
function setci(empcidetails)
{
var CIdetails = new GlideRecord('cmdb_ci');
CIdetails.addQuery('assigned_to', empcidetails.sys_id);
CIdetails.query();

while(CIdetails.next())
{
//alert(CIdetails);
//alert('CI is '+CIdetails);
var a=CIdetails.sys_id;
// alert(a);
g_form.setValue('configuration_item',a);
}
}

 

Thanks, 

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

View solution in original post

9 REPLIES 9

Jaspal Singh
Mega Patron
Mega Patron

Hi Sonali,

 

Can you kindly help with the script once & confirm if the record is actually present in the table being referenced.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

sonalin
Tera Expert

Hello Jaspal,

 

Yes The Record is already present on the Computer[cmdb_ci_computer] Table.

Below is the script I am using to display this Value. I also tried using the [cmdb_ci] table. Still no luck.

This CI  Reference value is not getting displayed to the Variable Configuration Item, however when I update the status value in the workflow, the run-script successfully updates the status.

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
    if (newValue) {
    
    var empcidetails = g_form.getReference('employee_user_name');
    var userID = empcidetails.user_name;
        
        var CIdetails = new GlideRecord('cmdb_ci_computer');
                CIdetails.addQuery('assigned_to', newValue);
                CIdetails.query();
        
        while(CIdetails.next())
{
//g_form.setValue('cmdb_ci', ci.name);
    g_form.setValue('configuration_item', CIdetails.name);
    
}
      
    }
    
            
}

Hi Sonali,

 

Can you try something as below.

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
  //  if (newValue) {
    
    var empcidetails = g_form.getValue('employee_user_name');

alert('User is '+empcidetails);

 

 var CIdetails = new GlideRecord('cmdb_ci_computer');
                CIdetails.addQuery('assigned_to', empcidetails);
                CIdetails.query();
        
        while(CIdetails.next())
{

alert('CI is '+CIdetails);
    g_form.setValue('configuration_item', CIdetails);   
}
      
  //  }
    
            
}

 

Kindly confirm the alerts what you get.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

sonalin
Tera Expert

Hi Jaspal,

If we see the configuration Item on the Incident from, there seems to be reference qualifier and the value is refereed from  Task table. Do we need to create a reference qualifier for this?

Thanks,