Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: Advanced Services: Using an Action to populate a dropdown?

$
0
0

sbeaver,

 

Thanks for the reply...

The data I am looking to retrieve is fixed (At least for now!).

So the code contains the Database (corpa.cmdb) and Table (dbo.Env) to access:

 

var databaseParameter = "corpa.cmdb";

var query = "Select Designation, Description from dbo.Env";

return databaseParameter.readCustomQuery(query);

 

I have made an additional attempt since posted but I am still not getting any results!

Below is the latest code I am trying to use for the action:

 

var databases = SQLDatabaseManager.getDatabases();

//  a variable to hold our database

var database = null;

 

// loop through them until we find our database, using the friendly name we configured

for each (var db in databases) {

    if (db.name == "corpa.cmdb") {

        database = db;

        break;

    }

}

 

// a bit of checking to make sure our database was found

if (database == null) {

    throw "Unable to find database!";

}

 

var query = "";

query += "select";

query += "    Designation as Value,";

query += "    Description as Label";

query += " from";

query += "    dbo.Env";

query += " order by";

query += "    Value asc";

 

// execute the query

var result = database.readCustomQuery(query);

 

// a bit of info to log

System.debug("Database query for Environments returned " + result.length + " records");

 

var data = new Array();

for (var i = 0; i < result.length; i++) {

    System.debug("Found Environment: " + result[i].getProperty("Value"));

    data[i] = result[i].getProperty("Vale");

}

// return the data

return data;

 

Bill S.


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>