We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

CMDB

JinkaH
Tera Contributor

Could you please provide assistance for this to identify orphan CI 
Where all CI status is installed and CI type is not empty and ownedby.active=false.
All the CIS which match the above filter condition and where Owned By.Active=False and Owned By.Dormant=False and OwnedBy.Deactivation Date Is not Empty should fail the certification and  be marked as non-compliant CIs.
The audit should be run on daily basis and should executed @3AM CET

No Task creation required


the CIs which are in status installed are owned by user which is Active =False and Dormant=False are marked as non-compliant and as report as non-compliant CIs in the Compliance metrics of the CMDB Health Dashboard and as well each of the failed CIs must be available in cert_audit_result and the cmdb_health_result table bydefault as part of the standard Service Now process.


Please provide the assistance related to this requirement to design the solution.

(function executeAudit(current, answer) {

if (gs.nil(current.owned_by)){
return false;
}


var owner = current.owned_by.getRefRecord();

if (!owner || !owner.isValidRecord())

return false;

var inactive = owner.active == false;

// Replace with actual field names from sys_user
var dormant = owner.u_dormant == true;
var deactivationDate = owner.u_deactivation_date;

if (inactive &&
!dormant &&
!gs.nil(deactivationDate)) {

answer = false; // Non-compliant
return;
}

answer = true; // Compliant

})(current, answer);

This is the code i had used 
But it is not executed and results are not coming in cert_audit_result.list table 
Is there any mistake in the code could you please assist



1 ACCEPTED SOLUTION

abbasshaik4
Tera Sage

Hello @JinkaH,

 

Please refer to the link below:
Solved: Re: Best Practise to handle Orphan CIs - ServiceNow Community

 

If it is helpful, please mark it as helpful and accept the correct solution by refer to this solution in the future it will be helpful to them.

 

Thanks & Regards,

Abbas Shaik

View solution in original post

1 REPLY 1

abbasshaik4
Tera Sage

Hello @JinkaH,

 

Please refer to the link below:
Solved: Re: Best Practise to handle Orphan CIs - ServiceNow Community

 

If it is helpful, please mark it as helpful and accept the correct solution by refer to this solution in the future it will be helpful to them.

 

Thanks & Regards,

Abbas Shaik