Highlighted
Absent Member.. Absent Member..
Absent Member..
1182 views

How to add a Javascript event on True Client

Hi everyone,

Can anyone share me a snippet of code for adding a "onkeyup" event on a field into true client. 

I am not a expert in True client, and I am not usualy scripting with this protocol. 

Thanks for your response

Romain

0 Likes
3 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: How to add a Javascript event on True Client

Hi Romain,

You can evaluate custom JavaScript code using the "Evalue JavaScript" step.

I'm not sure I understand what adding an event into TruClient means.

Can you elaborate on your application and scripting needs?

 

Edo

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

Re: How to add a Javascript event on True Client

Thanks for you reply,

Here is the Javascript function  I would like to call on my TC script onkeyup="UpdateOutput('Screen_7_4','UserInput').Value(this);"

This occurs a autosubmit in a particular iframe in my application. 

TC doesn't record the submit, so I have to add a "Evaluate Javascript "step to force it to execute this onkeyup.

Let me know if you need more explanation.

Cheers

Romain

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to add a Javascript event on True Client

Hi,

This handler accept the object on which the operation was done as an argument. While you can trigger a function in the docuemnt using JavaScript code from TruClient you will also need to supply the object as the argument. Since we are talking about logic that resides in an iframe it will be pretty challenging to explain and troubleshoot over here.

I suggest trying the following steps:

1. Drop a Generic Object Action step from the Toolbox

2. Select the object on which you wish to perform the action

3. Change the action in the step editor from Click to Evaluate Javascript

4. Add the following code in the Code Argument of the step

var e = document.createEvent('HTMLEvents');
e.initEvent("keyup", false, true);
object.dispatchEvent(e); // object is the object that was found by TruClient in this step

Regards,

Shlomi

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.