The CreatorCon Call for Content is officially open! Get started here.

Need Assistance with Custom table

Community Alums
Not applicable

Hi All,

 

I have to create one custom table with a copy of App Category is Component from cmdb_ci_appl table.

Note: This custom table should NOT be under CMDB and is not a new CI Class. Only a generic custom table.

 

Custom table named: u_custom_table  (This custom table has limited fields i.e 4 or 5 columns from application table)
Has all records of App CI of App Category = Application Component
Field values is updated and kept in sync with App CI field changes (for this one I am thinking to create after insert/update BR)

 

For initial data import from cmdb_ci_appl table to custom table how I proceed?

2 REPLIES 2

Daniel Borkowi1
Mega Sage

Hi @Community Alums,

the Use Case behind would be interesting for me. But I would write a Fix Script copying this from one table to the other and Run this in background:

var grAppl = new GlideRecord('cmdb_ci_appl');
grAppl.query();

while (grAppl.next()){
   var grNewRecord = new GlideRecord('u_custom_table');
   grNewRecord.intialize();
   grNewRecord.setValue('u_fieldX', grAppl.getValue('fieldX'));
   grNewRecord.insert();
}

 

Greets
Daniel

Please mark reply as Helpful/Correct, if applicable. Thanks! 

SebastianKunzke
Kilo Sage

Beside the point, that I do not know, why you need a custom table (In my point of view some custom fields on the exisiting table would be enough), I would suggest to build an on demand flow.

You could make a look up records to the cmdb_ci_appl table, afterwards for each Create record in the custom table. With this function you would be able to take over only partial of the data or all based on your look up definition.

I hope that answer will help you.