Highlighted
Contributor.
Contributor.
829 views

Calling Javascript function - Truclient script

Hello Friends,

I am stuck with issue of calling the javascript function which i have written within the scope of TRANSACTION.

The function simply returns the transaction response time. See below:

1.PNG

The function is placed in EvalJS Step and calling it after the END transaction. See below:

2.png

When I run this script, I get an error unknown function getResponseTime() - which is expected. 

Can someone let me know what is the correct way of calling this function to return me the response time value.

My original idea is -  at step 24 - my java script code wiill make an entry into influx db with the above response time

 

0 Likes
3 Replies
Highlighted
Contributor.
Contributor.

Re: Calling Javascript function - Truclient script

Are the images visible  to everyone?

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Calling Javascript function - Truclient script

I do not see an issue with your java script. I can simulate your function definition and call. At which LR version are you, I'm at 12.55.

But your logic needs improvement. You can call TC.transactionDuration() only on an open transaction and not after end-transaction.

Signature:
Reward community members who take time to respond and help.
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calling Javascript function - Truclient script

Hi @Anees200758,

@JHF Remmelzwaal is right. You need to call the function from within the context of the transaction and not after it ended.
In addition, the function definition as you defined it will not be recongnized by other steps. Instead, I suggest using a function inside a TruClient function library. That will be a more appropriate way to use.

Regards,
Shlomi

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.