How to move one table of related list records into another table of related list table

chanikya
Tera Guru

My request is: i would like to see software installation records under  Computers(cmdb_ci_computer)  table of related list table Software installations....

 

In Both tables - Related list table is same (software installation)

Condition: computer table of record name and Arrived computer of record name if it match then only move related table records from Arrived computer table related record's.. 

howcan i do it..

My script is not working....Schedule Jobs

var comp = new GlideRecord('cmdb_ci_computer');
comp.addQuery('u_computername',current.sys_id);
comp.query();
while(comp.next()){
var arc = new GlideRecord('u_arrived_computers');
arc.addQuery('name',comp.name);
arc.query();
if(arc.next()){
var soft = new GlideRecord('cmdb_sam_sw_install');
soft.addQuery('u_computername',arc.sys_id);
soft.query();
while(soft.next()){
gs.log(soft.getRowCount());
soft.u_computername= comp.sys_id;
soft.update();
}
}
}

Here , if you click on computer name it is navigated into Arrived computer table..

find_real_file.png

 

find_real_file.png 

 

 

i wanna see installations record under computer record

find_real_file.png

 

 

if you wanna more information i can explain you clearly .....

please help me here, where i am going wrong here

1 ACCEPTED SOLUTION

So every time you insert or update  computer, it will query the software installation table with computer name field in software installation same as the name of the computer you are creating.

 

var software = new GlideRecord('cmdb_sam_sw_install');
software.addQuery('u_computername.name',current.name);
software.query();
while (software.next())

{

// If it finds the records, it will update the existing archived computer name with the new computer name
software.u_computername = current.sys_id;
software.update();
}


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

33 REPLIES 33

okay, i will Give Screenshots of My TEST instance screen pics... 

there is an variation ..

in TEST :  

Software Installation table records are coming from SCCM integration so , here we are not creating any manual installation records

find_real_file.png

 

here Computer field  mapped with Hardware table

find_real_file.png

 

find_real_file.png

 

find_real_file.png

 

 

 

In Computer Table we are creating records manually only....

when i create record with Same computer name in Computer Table, then move installation records from Hardware table to Computer table 

find_real_file.png

I think you are not doing it correctly. There will be a configuration item field in the alm_hardware table. When the record in cmdb_ci_comp table, it should be linked to the asset/hardware record. 

And what is the use of u_arrived_computer table then?


Please mark this response as correct or helpful if it assisted you with your question.

basically , they want to create  reports on specifics computer names..

if see in hardware a roundly there are 2840 computer records are there,  they don't want that much of all computer info,

for this case they selected some Limited computer names just 10 or 15 computer records  and created records in computer table with same of computer name which is available in hardware table.

 

 

 

Last time i tried with this script to populate records, but still not working....

var comp = new GlideRecord('cmdb_ci_computer');
comp.addQuery('u_computername',current.sys_id);
comp.query();
while(comp.next()){
var arc = new GlideRecord('cmdb_ci_hardware');
arc.addQuery('name',comp.name);
arc.query();
if(arc.next()){
var soft = new GlideRecord('cmdb_sam_sw_install');
soft.addQuery('u_computername', arc.sys_id);
soft.query();
while(soft.next())
{
gs.log(soft.getRowCount());
soft.u_computername = comp.sys_id;
soft.insert();
}
}
}

Can you post me a screenshot of what you have in u_arrived_computers table?

 

My understanding is, you are getting asset records in hardware and the corresponding software installation records getting tagged to the hardware record. 

Now when you manually create a record in cmdb_ci_comp table, the softwares should also tag to the computer record.

To do that, while creating record in cmdb_ci_comp, in the asset field, enter the record name you have in hardware table.

 

Then, you may have an out of box related list to display the list of software installation record to show under computer. If not, you need to create a Relationship record to display the software installations tagged to the corresponding hardware record.


Please mark this response as correct or helpful if it assisted you with your question.

 Please bare with me ...

For testing purpose in Dev instance we have created one new table  u_arrived_computers  as field reference table Instead of Hardware table under u_computername field, 

usually there is a  Hardware table we have taken  in TEST, PROD instances....

for this case only i have provided TEST instances pics............... 

 

 

How can we get records into computer record ................???

Please tell me that how to create bridge b/w computer and hardware to get installation records....

here we don't have any chance to add a value in the asset field, enter the record name you have in hardware table.

If not, how to create a Relationship record to display the software installations tagged to the corresponding hardware record.

 

for this case just now  i have create one new filed Asset: reference field, reference table is Hardware.........

now what we have to do.....still not populating installation records..........?