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

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

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

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

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.

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

Share the output from the SQL Custom Action step. Are you able to see the output (count) there?

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

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

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

The variableName says 'Total' inside the Custom Action. Change the javascript to Total_COUNT_1. Please note JavaScript is case sensitive.

Shruthi H.
Shruthi H.

Shruthi H.

Level
1
105 / 750
points

I have changed it.But still facing the same issue

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

Can you try to change the query to select * from table to see if you see any output in the custom action?

In the screenshot, I see it being blank.

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?

Rajagopal B.
Rajagopal B.

Rajagopal B.

Level
1
346 / 750
points

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!!!