Highlighted
Valued Contributor.
Valued Contributor.
686 views

Quering the VTS tables

IS there a way we can query the VTS Table while using TruClient-IE.?

I need to have a users table and I need one  script to extract System Admins ( a role column in the users table) and another script to extract the users ( the same role column in the same table).

Or do I have to have a System Admins vts table and a Users vtstable?

0 Likes
8 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Quering the VTS tables

Hi,

 

Yes the same VTS commands can be used for TC scripts as well.

 

 

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Quering the VTS tables

 I am not sure you understood my question:

is there a command where I can extract data from a table using where clause so I want to get the Usernames from the table users where the role = "SystemAdmin"

something like this:

vtsUserName = LR.vtcGetCell("UserName",vtsUIndex,"vtsUsers where role = 'SystemAdmin");

 

 

 

 

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Quering the VTS tables

How to use Eval JavaScript code step to pass VTS parameters to another step.
You can use the Eval JavaScript code step to pass VTS parameters to another step in your script. The
example below shows you how to parametrize a URL.
1. Connect to a VTS server
a. Select Toolbox > Miscellaneous and add an step to your script.
b. To connect to a VTS, enter TC.vtcConnect(“server”,port,"alias") in the Arguments >
Code section of the step.
2. Create a step that contains a variable.
a. Select Toolbox > Miscellaneous and add an step to your script.
b. In Argument > Code section enter define your variable.
For example, to get data from the server enter var ws = TC.vtcGetCell("Web
Sites",1,"alias");
3. Select Toolbox > Functions and add a Generic Browser Action to your script.
4. Enter the variable you defined in Step 2 in Argument > Location .
How to use a VTS API function directly in a step.
You can use the Eval JavaScript code step implement a VTS API in your script. The example below shows
you how to parametrize a URL.
1. Connect to a VTS server
a. Select Toolbox > Miscellaneous and add an step to your script.
b. To connect to a VTS, enter TC.vtcConnect(“server”,port,"alias") in the Arguments >
Code section of the step.
2. Select Toolbox > Functions and add a Generic Browser Action to your script.
3. Enter TC.vtcGetCell("Web Sites",1,"alias");in the Argument > Location section of the
script..

Highlighted
Valued Contributor.
Valued Contributor.

Re: Quering the VTS tables

Thanks for your response, I understand that, I am asking if you can extract a value from a column based on another value. so in the last step you mentioned can you do  TC.vtcGetCell("Web Sites",1,"alias"); where type = 'Test' for example.

 

0 Likes
Highlighted
Established Member..
Established Member..

Re: Quering the VTS tables

Hi

As far as I know there isn't any API of VTS which will allow you to do that.

The solution is programmatically.

You can use the following code in "Evaluate JavaScript" step:

//Table contain 2 columns : Name & Role

//Option1 - Getting all admin users into array. Both script can use this code\share it via external lib
// The data for example can be re-inserted in different columns that will represent the admin users

//Connect to the server
TC.vtcConnect("127.0.0.1", 8888, "MyVTS");

//Get the user count
var usersCount = TC.vtcColumnSize("Name", "MyVTS");
TC.log("usersCount = " + usersCount, "Standard");

//Create new column for results and clear it. (2nd run it will not be created, just cleared)
TC.vtcCreateColumn("adminUsers", "MyVTS");
TC.vtcClearColumn("adminUsers", "MyVTS");

var adminUsers = [];
//Loop over the data, extract it to array and insert it in dedicated column we created above
for (var i = 1; i <= usersCount; i++){
     var user = TC.vtcGetRowCells(i, "MyVTS");
     if (user && user.Role == "admin"){
             //Add to the array
             adminUsers.push({user: user.Name, index: i});
            //Add back to the VTS table
            TC.vtcAddCell("adminUsers", user.Name, "MyVTS");
     }
}
TC.log(JSON.stringify(adminUsers), "Standard");

//Disconnect from server
TC.vtcDisconnect("MyVTS");

 

Asaf Alster

TruClient R&D

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Quering the VTS tables

Thank you for your response,  so having the data in the array is more efficient, or using another instance of a vts table for one for users and one for SystemAdmins?

 

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Quering the VTS tables

I've only started researching VTS - Is my understanding incorrect thinking that you can have two columns in the VTS, lets say "Users", and "SupervisorUsers", and query them back seperately.

 

TC.vtcConnect("localhost",8080,"myVTSAlias");
…
vUser = TC.vtcGetCell("Users",1,"myVTSAlias");
vSupUser = TC.vtcGetCell("SupervisorUsers",1,"myVTSAlias");

 

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Quering the VTS tables

no your understanding is correct for the example you have given of  two columns one is a "User" and the other is a "SupervisorUser"

But my question was for a different format of the table, if I use the same example you provideed it would be:

if the columns were username and userRole and the role has value of either"User" or "SupervisorUser". 

That way I think you have to either use the array that is suggessted above or use two different instances of the vts tables one for Users and one for SupervisorUsers.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.