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

need to return ci servers in my report

Deepthi13
Tera Expert

 

 i

4 REPLIES 4

Jake Sadler
Kilo Sage

Hello @Deepthi13 ,

 

Try using global.ActiveInactiveABO().getActiveOwnedServers();

 

and in the script return do this:

return activeServers.toString();  // Return the array of server CI identifiers

still not coming
Deepthi13_0-1723021803249.png

var ActiveInactiveABO = Class.create();
ActiveInactiveABO.prototype = {
    initialize: function() {
    },

    getActiveOwnedServers: function() {
        gs.info("first&&&& ");
        var activeServers = [];  // Array to store server CI identifiers
        var gr = new GlideRecord("cmdb_ci_server");
        gr.query();

        while (gr.next()) {
            gs.info("second&&&& ");
            var user = new GlideRecord("sys_user");
            user.addQuery("name", gr.u_abo_application_owner);  // Assuming 'u_abo_application_owner' is a string field
            user.addQuery("active", true);  // Ensure the user is active
            user.query();

            if (user.hasNext()) {  // Check if there is at least one active user
                activeServers.push(gr.getValue("sys_id"));  // Add the server's sys_id to the array
            }
        }
gs.info("&&&& "+activeServers);
return activeServers.toString();  // Return the array of server CI identifiers
     // Return the array of server CI identifiers
    },

    type: 'ActiveInactiveABO'
  1. };

hope this is fine?

 

Is gr.u_abo_application_owner a reference field? If so you may need to use gr.u_abo_application_owner.name or   user.addQuery("sys_id", gr.u_abo_application_owner.sys_id);

 

Do all logs come out? Put one inside the if statement to return the user name

Bhavya11
Kilo Patron

Hi @Deepthi13 ,

 

Can you try Client callable script include. it will work.

 

Thanks,

BK

 

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,
BK