Unanswered question

Custom Actions- Unable to read output of the query?

I have tried the below using custom actions:
type: QUERY
connectionURL:jdbc:microsoft:sqlserver://server_name:1433
connection.user: my_user_name
connection.password: my_password
sqlStatement: SELECT count(*) FROM [employee].[dbo].[tblProductSales]
variableName: Count
Command:

I am unable to get the result of the query either in Details/Variables Tab of Check Virtual User Window.And also I am getting response code for this Custom Action as 0.

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

Answers

The output will be saved as "Count_<column name>_<row number>" in your case, Count_COUNT_1 should have the output.

You can use a Javascript to read the output and save it in a variable and use it.

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

Thanks for the reply.

Can you provide the sample code to read the output using javascript? And also I didn't understand why we need to specify Column name(Count_<column name>_<row number>),as here I am trying to get the total count of the records

If you execute Select * from <Tablename> then you may get more than 1 column and 1 row and to get a specific cell you can specify the column name and row number to get values. Column information would be "Column Name" and row information would be the "row number". In your case, the column name would be "COUNT" and there will be only 1 row so you need to specify that specific value.

Sample code:

var myVar = context.variableManager.getValue("Count_COUNT_1");

context.variableManager.setValue("<Neoload_VariableName>",myVar);

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

I am not able to get the count by using the sample code.

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

No..I am not able to find the ouput.
Find the attachments

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

I have changed it.But still facing the same issue

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

I have tried using "select * from table" query with javascript variable as Total_<Column Name>_1.But still unable to read the value.

If at all you have tried it.Can you share the script?

Please attach screenshots of the custom action and the output of the custom action.

When you execute the following query in SQL server you are able to get output?
SELECT * FROM [employee].[dbo].[tblProductSales]

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

I am unable to get the output.Please find the attachments....

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

Havn't received any reply!!!