Update fields EOL / EOS of cmdb_ci table depending upon values in the custom table. [ See description for details]

Sachin Gavhane
Giga Guru

I have created a custom table "eoleos" as shown below:

find_real_file.png

field --> Type (choice) Choices are : Operating System , Database Server , Network Device , ATM

EOL/ EOL are date and remaining all fields are string.

User will enter details in all the above fields in the custom table "eoleos".

Requirement is : 

When insert or update on above table "eoleos"

if type == Operating System

then

Match Name & version/Model mentioned in above custom table with CMDB_CI table (Operating System, OS version) and update OS EOL & OS EOS of cmdb_ci table from the above custom table.

can someone help me in this requirement.

@shloke04 can you please help me

appreciate your time and efforts

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

@Sachin Gavhane 

Couple of points to note here:

1) Updating CMDB CI table with EOL and EOS values from your custom table is okay but which class of CMDB CI you want to update here?

So please make sure you update the correct class when updating the values, I am sharing the script to be used here you just need to update the correct table Name here in script below it can be Hardware, Network or Computer or the class you want:

BR Details:

Table Name: eoleos

When: After Insert and Update

Condition: Type is Operating System

Script:

Current in script below refer to EOLOS table field object. So replace the field Name and value properly and you should be good with your requirement.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	updateCITable(current);
	
	function updateCITable(current){
		var gr = new GlideRecord('Table Name here');
		gr.addQuery('name',current.name);
		gr.addQuery('version',current.version);
		gr.addQuery('model_id',current.model);
		gr.query();
		while(gr.next()){
			gr.FIELD_NAME = current.EOL_FIELD_NAME;
			gr.FIELD_NAME = current.EOS_FIELD_NAME;
			gr.update();
			
		}
		
	}

})(current, previous);

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

7 REPLIES 7

also many fields are not directly on cmdb_ci table then how it will work?

can we gliderecord to directly those tables, example: Hardware EOL is not on cmdb_ci so dot walking is not possible, I guess we need to directly gliderecord on cmdb_ci_hardware table.

 

Is my understanding correct?

Question - which table contain the field Hardware EOL? From which table you need to update this field value?

 

In case it is not in cmdb_ci then you need to glide it to (cmdb_ci_hardware) related table to which the field is created and then update the related field (for ex. Hardware EOL) then.

 

Hope this helps.

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

shloke04
Kilo Patron

@Sachin Gavhane 

Couple of points to note here:

1) Updating CMDB CI table with EOL and EOS values from your custom table is okay but which class of CMDB CI you want to update here?

So please make sure you update the correct class when updating the values, I am sharing the script to be used here you just need to update the correct table Name here in script below it can be Hardware, Network or Computer or the class you want:

BR Details:

Table Name: eoleos

When: After Insert and Update

Condition: Type is Operating System

Script:

Current in script below refer to EOLOS table field object. So replace the field Name and value properly and you should be good with your requirement.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	updateCITable(current);
	
	function updateCITable(current){
		var gr = new GlideRecord('Table Name here');
		gr.addQuery('name',current.name);
		gr.addQuery('version',current.version);
		gr.addQuery('model_id',current.model);
		gr.query();
		while(gr.next()){
			gr.FIELD_NAME = current.EOL_FIELD_NAME;
			gr.FIELD_NAME = current.EOS_FIELD_NAME;
			gr.update();
			
		}
		
	}

})(current, previous);

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke