Highlighted
Trusted Contributor.
Trusted Contributor.
1467 views

problem using web_js_run() function

Jump to solution

HI all,

i am calling a code.js file through web_js_run() function. Basically i want to pass a string which will be encrypted by javascript.

I am trying below function

web_js_run(
    "Code= encrypt('SampleString')",
    "ResultParam=param1",
    SOURCES,
    "File=code.js", ENDITEM,
    LAST);

And i am getting proper encrypted string. As soon as i replace it wth variable it stops working. error is "var1 is not defined"

web_js_run(
    "Code= encrypt({Var1})",
    "ResultParam=param1",
    SOURCES,
    "File=code.js", ENDITEM,
    LAST);;

I tried another way,

char *tmp=lr_eval_string("encrypt({var1})");

web_js_run(
    "Code= {temp}",
    "ResultParam=param1",
    SOURCES,
    "File=code.js", ENDITEM,
    LAST);

The above code is also giving me error " temp is not defined"

Please not that "var1" is the data which i need to pass trough csv file which i have declared in parameters.

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

with some trial n error i got the solution.

 

web_js_run(
    "Code= encrypt('{Var1}')",
    "ResultParam=param1",
    SOURCES,
    "File=code.js", ENDITEM,
    LAST);

View solution in original post

0 Likes
2 Replies
Highlighted
Trusted Contributor.
Trusted Contributor.

with some trial n error i got the solution.

 

web_js_run(
    "Code= encrypt('{Var1}')",
    "ResultParam=param1",
    SOURCES,
    "File=code.js", ENDITEM,
    LAST);

View solution in original post

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

I want to convert a value into HTML to URL and need to pass html value as a parameter.

Solution 1: without passing parameter

web_js_run("Code=EncURI(\"670523   X\");",
        "ResultParam=EURI",
        SOURCES,
        "Code= var EncURI = function(uri) { return encodeURI(uri);}", ENDITEM,
        LAST);

Output: 

Action.c(12): web_js_run was successful [MsgId: MMSG-26392]
Action.c(16): web_js_run started [MsgId: MMSG-26355]
Action.c(16): Notify: Saving Parameter "EURI = 670523%20%20%20X".

 

Solution 2: passing with a parameter

step1: Create a parameter called "enc" and pass the parameter using LR.getParam.

Step2:

web_js_run("Code=EncURI(LR.getParam('enc'));",
        "ResultParam=EURI1",
        SOURCES,
        "Code= var EncURI = function(uri) { return encodeURI(uri);}", ENDITEM,
        LAST);

 

output:

Action.c(12): web_js_run was successful [MsgId: MMSG-26392]
Action.c(16): web_js_run started [MsgId: MMSG-26355]
Action.c(16): Notify: Saving Parameter "EURI = 670523%20%20%20X".

 

 

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.