- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 11:31 AM
Step 1 : I have created a custom field named "datacertificationstatus" on cmdb_ci table
Step 2 : In OOB data certification task, if any element is certified then associated CIs in cmdb_ci table should display value as "certified" for the above custom field created in cmdb_ci table
if we certify above elements then respective CIs in cmdb_ci table should display value as "certified" for the custom field "datacertificationstatus" in cmdb_ci table
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2022 12:15 AM
Hi
There was a flaw in the script shared before where I forgot to pass the parameter correctly when it need to be certified.
So have updated the script , please use the same and test. I have tested it and works fine for me now.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var getCI = current.id;
var gettargetTable = current.table;
var getAllDetails = CheckCIColumn(getCI);
if (getAllDetails == true) {
updateCI(gettargetTable,getCI);
}
function CheckCIColumn(CI) {
var gr = new GlideRecord('cert_audit_result');
gr.addQuery('id', CI);
gr.addQuery('state','Pending'); // This will check if there are any un Certified records or not.
gr.query();
if (gr.next()) {
gs.info('There are still record which are not certified. So please certify first');
return false;
}else{
return true;
}
}
function updateCI(gettargetTable,getCI) {
var gr = new GlideRecord(gettargetTable);
gr.addQuery('sys_id', getCI);
gr.query();
if (gr.next()) {
gr.short_description = 'certified'; // Please make sure to replace "certified" with its correct back end value here and and also replace "FieldName" with the correct field name which you want to set.
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-03-2022 04:34 AM
Hi
Okay. Please update your script as below:
Business Rule details remain same , you just need to update the same script as below:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var getCI = current.id;
var gettargetTable = current.table;
var getAllDetails = CheckCIColumn(getCI);
if (getAllDetails == true) {
updateCI();
}
function CheckCIColumn(CI) {
var gr = new GlideRecord('cert_audit_result');
gr.addQuery('id', CI);
gr.addQuery('state','Pending'); // This will check if there are any un Certified records or not.
gr.query();
if (gr.next()) {
gs.info('There are still record which are not certified. So please certify first');
return false;
}else{
return true;
}
}
function updateCI() {
var gr = new GlideRecord(gettargetTable);
gr.addQuery('sys_id', getCI);
gr.query();
if (gr.next()) {
gr.short_description = 'certified'; // Please make sure to replace "certified" with its correct back end value here and and also replace "FieldName" with the correct field name which you want to set.
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-03-2022 06:29 AM
Hi
I am not able to get pending CIs of that row
I have written same script
In line no 14 I have replace id by sys_id , is that correct?
I tried executing the code but even if all CIs in the row are not certified still custom field gets value certified
here, CI named idncs10101295 in CMDB_CI table is updated with certified value for that custom field but as you can see serial number was not certified
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 08:10 AM
ID will remain as ID. ID is the field name for document which stores the CI details.
So please use the same exact script and that should work for you.
In above script you just need to replace the field name and value of certified in line below and nothing else.
gr.short_description = 'certified'; /
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-03-2022 12:04 PM
I tried a lot ,
certified all the elements on the row , but still code is returing false,
In the above document ID , i certified all the 11 elements but still code is returning flase
code written is as follows
even if i certify all the elements in single row , still it return false.
can you please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2022 12:09 AM
in cert_audit_result table, i guess we should filter by follow on task as well, becoz getci can be on multiple tasks.
I have filtered on cert audit result table but every time it returing true