- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 12:28 AM
I have created a custom table "eoleos" as shown below:
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.
appreciate your time and efforts
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 04:32 AM
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
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 03:26 AM
Hi,
Use below script for your requirement -
Business Rule - After (Insert and Update)
Table - eoleos
Condition - Type isOneOf "Operating System , Database Server , Network Device , ATM"
var name = current.name_field_name;
var version = current.version_field_name;
var grCmdb = new GlideRecord('cmdb_ci');
grCmdb.addQuery('operating_system_field',name);
grCmdb.addQuery('os_version',version);
grCmdb.query();
if(grCmdb.next()){
current.eol_filed = grCmdb.os_eol_field_name;
current.eos_filed = grCmdb.os_eos_field_name;
current.update();
}
Mark this as Helpful/Correct, if Applicable.
Regards,
Sourabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 03:42 AM
Hi Sourabh,
can you help with the above requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 04:48 AM
Hi
i want to update the fields (eol/eos) of cmdb_ci table
so conent inside if we change right?
also many fields are not directly on cmdb_ci table then how it will work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 05:52 AM
okay in that case do the below change on the shared script above -
if(grCmdb.next()){
grCmdb.os_eol_field_name = current.eol_filed;
grCmdb.os_eos_field_name = current.eos_filed;
grCmdb.update();
}
also many fields are not directly on cmdb_ci table then how it will work?
In that case you need to dot walk to that field or else use setValue() method to update the value on that field.
Mark this as Helpful/Correct, if Applicable.
Regards,
Sourabh