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

can i expect any updates Sanjiv!

Create a Relationship record under system definition.Name it as Computer to Software Installation

 Applies to table is Computer table and Queries from table is Software Installation

 

Then in the script section write

current.addQuery('u_computername',current.u_assets);

 

Save this relation. And then open the form layout for cmdb_ci_comp table and click on Configure->Related List and add Computer to Software Installation you created.


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

computer record:  TT-MELIE , created related this installation records are 115

but in u_assets i have takedn: RQ-NOGENEROSO , this total installation records are 144

 

i request you here, is it possible to maintain both names should be same 

if we create a record in Computer table with  TT-MELIE then display  TT-MELIE  name in u_assets field if  TT-MELIE is available in Hardware table other wise it should be empty. 

 

You can write a business rule on Computer table to do that. onBefore Insert/Update Business Rule

 

var asset = new GlideRecord('alm_hardware');

asset.addQuery('name',current.name);

asset.query();

 

if (asset.next())

{

current.u_asset = asset.sys_id;

}


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

Hi Sanjiv,

 

Thanks for your reply..

instead of all this relation list setups,  can we copy/move hardware records of installtions records into Computer record???

 

is there any chance using with script? because based on computer names and related list Software installation records should display counting in Software counter 

By using this Relatedlist "computer to Software installations" counting is not geeting into Software coutnter