Hi,
currently, I want to create a Workflow with the vRealize Orchestrator and I want to transfer input parameters into the MDT (Microsoft Deployment Tool) database, so the MDT can start a automated Windows Server installation.
This is how it should work:
I create a new VM and the created MacAdress of the first Adapter should be added to the MDT SQL table, so the WindowsPE from the MDT recognize, which settings should be applied.
I also want to implement the input parameters like computername, etc into the MDT database.
The problem now is, that I want to add the MacAddress to the table with the macadresse and after adding it, I want to select the newly created ID, with the creation of the MacAddress, after that I want to use this newly created ID and add it into another table, so the system understand, that the values are connected from the both tables.
I was able to add the MacAddress with the workflow "Create active record for 'tablename'. And the SQL Server generated the next free ID. Now I want to take this newly created ID and add it into another table with other values, how can I do that? If I use the workflow "Read active record for 'tablename', i just get a array, but I don't know how to use this result as a string (ID), so I can connect it to the next "create active record..." workflow.
Thanks you, I hope you understand, what I mean
.
Check out this series of blog articles: http://www.vcoportal.de/2012/07/introducing-the-littlecmdb-a-vcenter-orchestrator-wavemaker-demo-pro...
If I remember right, it contains some logic for your scenario...
Last resort: You can always "fall back" to use native JDBC objects and calls to run whatever SQL query you want. It's just more effort to develop the needed javascript logic...
Joerg
The generated 'Read active record for 'table'' workflow returns result of type Array/SQLActiveRecord. (you can check description of SQLActiveRecord scripting object in vRO API Explorer).
The first step is to find your record in this array of records. Did you apply any filtering when executing the workflow? Even if you haven't, perhaps the record you want is the last record in the table, so you can retrieve it with a scripting code like:
var record;
if (result.length > 0) {
record = result[result.length - 1];
} else {
// somehow handle the situation when there are no records in the table
}
Then, you need to know what is the name of the table column containing the ID. Let's say the column name is 'idcolumn'. Then, you can fetch its value from the active record from the above step using a code like
var idvalue = record.getProperty("idcolumn");
Thanks for the help.
I was able to get the ID out of the SQL DB, using the JDBCConnection. At the end, I get the latest ID and I can use this ID, to write into another table.
IN: url, user, password, sqlstatement
Out: newID
sqlstatement: SELECT ID FROM dbo.ComputerIdentity WHERE ID = (SELECT MAX(ID) FROM dbo.ComputerIdentity);
var main = new JDBCConnection();
var stmt;
var rs;
var con;
con = main.getConnection( url, user, password );
System.log( "Connection to database successful" );
stmt = con.createStatement();
rs = stmt.executeQuery(sqlStatement);
while(rs.next()){
//Retrieve by column name
newID = rs.getString("id");
}
rs.close();
System.log(newID)
