Community in read only mode June 18 & 19
This community will be set in READ ONLY mode for a while on Tuesday June 18 into Wednesday June 19 while we import content and users from our Micro Focus Forums community site. MORE INFORMATION
Highlighted
Trusted Contributor.. CR Trusted Contributor..
Trusted Contributor..
826 views

using external js function within trueclient js action script

Jump to solution

Dear all,

I'm tryng to script on trueclient web protocol. Since I have common code parts I would lke to create a js library gathering all the common functions and call it within each script. I've created an external file .js I've called the API  TCS.utils.callJSFile to load the library within the js script (Action part) 

TCS.utils.callJSFile({"File Name": "lib.js" });

but I dont know how to call it 

lib.namefunction();  or just function() don't work I get the error " Syntax error in the script:ReferenceError: namefunction is not defined

Thanks

Best Regards

Christian

 

 

0 Likes
1 Solution

Accepted Solutions
litalr Contributor.
Contributor.

Re: using external js function within trueclient js action script

Jump to solution

Hi,

In order to be able to use the definitions from internal file called by callJSFile you need to define them as members of TCS.

For example:

TCS.Parameter = function (name, type, value, index){
this.name=name;
this.type=type;
this.value=value;
this.index=index;
}

 

and in action.js:

  var par = new TCS.Parameter("name", "type", "value", "index");

 

Thanks,

Lital

0 Likes
5 Replies
Jgor2810 Respected Contributor.
Respected Contributor.

Re: using external js function within trueclient js action script

Jump to solution

Hello,

Greetings,

Could you share the script that you are trying to modify and import the js so I can check this?

 

Also what results you get by using an evaluate js in TC script and add the code?

https://admhelp.microfocus.com/tc/en/12.56-12.57/Content/TruClient/procedures/_tc_t_insert_js_code.htm

 

jgor2810

0 Likes
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: using external js function within trueclient js action script

Jump to solution

Hi,

TCS.utils.callJSFile is supported only in Coded TruClient script, not in a Model based one.

Regards,
Shlomi

0 Likes
Trusted Contributor.. CR Trusted Contributor..
Trusted Contributor..

Re: using external js function within trueclient js action script

Jump to solution

Hi,

here is a sample code:

function Parameter(name, type, value, index){
this.name=name;
this.type=type;
this.value=value;
this.index=index;
}

var par=new Parameter("ParamName", "ParamType", "ParamValue",1);

Basically if I put the whole code within the action.js it works fine (compling and running);

If I create a simple file.js including  "Parameter" definition inside it then taking out it from action.js, adding  TCS.utils.callJSFile({"File Name": "file.js"});  and run it. I get an error on the object Parameter which definition is missing

0 Likes
Trusted Contributor.. CR Trusted Contributor..
Trusted Contributor..

Re: using external js function within trueclient js action script

Jump to solution

Hi,

yes i'm using full script code: objects and function are defined all together within the action.js. I would like to create some libraries and call them

0 Likes
litalr Contributor.
Contributor.

Re: using external js function within trueclient js action script

Jump to solution

Hi,

In order to be able to use the definitions from internal file called by callJSFile you need to define them as members of TCS.

For example:

TCS.Parameter = function (name, type, value, index){
this.name=name;
this.type=type;
this.value=value;
this.index=index;
}

 

and in action.js:

  var par = new TCS.Parameter("name", "type", "value", "index");

 

Thanks,

Lital

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.