Copy Device variable value to a field on software installation task table

UjwalaBedarkar
Tera Expert

Hi all,

 

I have created a string field on " sn_sam_software_installation_task" table called as Name, I want to copy the variable called "device" value into Name field So I am using the flow designer but I am getting below error.

 

UjwalaBedarkar_0-1744023231070.jpeg

 

but when I tried to add logs I am getting the correct value.

 

1 ACCEPTED SOLUTION

@UjwalaBedarkar 

if the field is on parent and you are creating record on child table then that field will be inherited so no issue in that.

I hope it's not the reverse

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

@UjwalaBedarkar 

it's a reference variable on that catalog item.

So did you try inline script and see if it works

var variableValue = fd_data._1__get_catalog_variables.device.toString();

gs.info(variableValue); // see what comes here

// now query that table being referred by device table with this sysId and get the name field

var gr = new GlideRecord("tableName");
gr.addQuery("sys_id", variableValue);
gr.query();
if (gr.next()) {
    gs.info(gr.name); // ensure you pick correct name field
    return gr.name.toString();  // ensure you pick correct name field
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@UjwalaBedarkar 

So are you sure that device where it's not working has name field as empty value?

Since it's an intermittent issue, it looks like a data issue and not config issue.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

I have tried with below script 

var deviceId = fd_data._1__get_catalog_variables.device.toString();
 gs.info("ujwala 1  device:"+deviceId); 
var grComputer = new GlideRecord('cmdb_ci_computer'); 
grComputer.addQuery('sys_id',deviceId); 
grComputer.query();
 if(grComputer.next())
{  
 gs.info("ujwala 2 name:"+grComputer.name.toString());  
 return grComputer.name.toString(); 
}

UjwalaBedarkar_0-1744032409735.jpeg

The logs is showing above value and the error is still same

@UjwalaBedarkar 

share the device variable config screenshot

I could see in logs it's already a GlideRecord object so try this

var deviceId = fd_data._1__get_catalog_variables.device.sys_id;
 gs.info("ujwala 1  device:"+deviceId);  // check if this prints the sysId of the device selected
var grComputer = new GlideRecord('cmdb_ci_computer'); 
grComputer.addQuery('sys_id',deviceId); 
grComputer.query();
 if(grComputer.next())
{  
 gs.info("ujwala 2 name:"+grComputer.name.toString());  
 return grComputer.name.toString(); 
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

UjwalaBedarkar_0-1744033792680.png

The logs are working now but error is there, even I tried to simply give a hardcoded value as test the error is still there.