New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class
546 views

Javascript returning & accessing multiple values

Hi,

 

I am trying to create a notification which will be based on 3 different values. These 3 values will be obtained through a JScall.

 

I am wondering if there's any way that i can access all these 3 values or put them into my notification condition. For instance, Javascript returns ["a","b","c"] for the function get3values(). How can i access the 3 values from the get3values() function?

0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

Use,
($val=jscall("jsname.get3values()"))

or like
if(jscall("jsname.get3values()") == "1") then dosomething else doother;

hth,
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
0 Likes
Highlighted
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi Piku,

 

Can i really do that ? My concern is because I will be returning 3 values. Will it actually check for all 3 values returned?

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi,

Are you simultaneously returning three values in array?
If so then $val will have like {"a", "b","c"} assuming return function is defined as array variable in JS, here you can easily try filter by if(1 in $val == "a") then do ; else skip;


hth,
____________________________________
Assign Kudo, if found post useful and mark it accepted if solves the issue.
0 Likes
Highlighted
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Yes Piku, will be returning 3 values simultaneously.

 

Even for me to assign values to $val, it won't be possible right ? If I am not getting this wrong, I would need to compare the values directly from the jscall function. Probably like the following code:

 

1 in jscall("jsname.get3values()") == "First Value"

 

I wonder if this will work. =D

0 Likes
Highlighted
Fleet Admiral
Fleet Admiral

Hi,

 

If I'm understanding your issue, I think it is the same one I experienced with a number of my notifications.  I couldn't figure out a way to only do the jscall once and then use the multiple values returned from that one call in different positions within my notification.  Using the 1 in jscall...., 2 in jscall etc would require a separate call anyway, so as a workaround I ended up splitting up the single function into three functions within the same ScriptLibrary record, so I had an individual RETURN from each function, and then I called them separately in different positions in the arguments of my notification.  This does work, if you need a workaround, but I would also be interested if anyone can tell you a way to bring all three values back from the same function call and use then separately in your notification.

 

Audrey

0 Likes
Highlighted
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

Hi Audrey, i have the same problem as you. My last resort will be to duplicate the same function into 3. =D

 

Let's hope some experts will someday drop by and give us a solution !

0 Likes
Highlighted
Ensign Ensign
Ensign

Hello,

 

"return" is array if I'm correct. And you need it in RAD expression, then return array should by Service Manager array, not JS array. 

How return array is created in script? Did you use push()? Then you get Service Manager array and it can by called 1 in $array.

 

 

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.