David_Teh Respected Contributor.
Respected Contributor.
1442 views

Help with scriptlet

Jump to solution

Hi all,

Trying to use a scriplet in the configuration to get the current date and time which is stored as a variable and I run into this error. Have tried to check for the meaning of the error but can't seem to find it. Capture.JPG

For reference, my script is as follows

Capture.JPG

I'm not sure whether its how I'm trying to call the script or whether its my script itself that's the problem. For now, I'm only trying to debug and will get this error. I couldn't find the flow variable at all which was why I was trying use the debug but got that error.

Just to add on, I have clicked the "Check Script" option which returns me a "No errors found." message.  

Thanks in advance for any help!
David

Labels (1)
0 Likes
1 Solution

Accepted Solutions
AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: Help with scriptlet

Jump to solution

You could to like this

Screenshot_44.pngScreenshot_45.pngScreenshot_46.png

Andrei Vasile Truta
7 Replies
David_Teh Respected Contributor.
Respected Contributor.

Re: Help with scriptlet

Jump to solution

I realised that my script was missing a try catch statement which caused the error. My debug now runs successfully but am still unable to call the flow variable which is supposed to be created as part of this script. Help with this point would be appreciated!

0 Likes
Bridges Respected Contributor.
Respected Contributor.

Re: Help with scriptlet

Jump to solution

Look at the 'Details' from the Error pop-up.  scriptletContext.putLocal is not valid.

As the template states:

// You can also place data into the local context, which means it will only be available to
// the current flow, but not to its parent flow or other subflows.  To do this:
scriptletContext.put("LocalVariable","LocalValue");

Instead use:  scriptletContext.put("currentTime",date); 

All the try/catch block did was catch your error.  It wasn't the solution.

 

 

 

David_Teh Respected Contributor.
Respected Contributor.

Re: Help with scriptlet

Jump to solution

HI Bridges,

Thanks for the clarification on the try/catch.
I have tried your suggestion on using put instead of putLocal. Forgot to mention that in additon to the try/catch,  I edited it to be putGlobal. Would like to ask what the difference between put and putGlobal be? I understand that putGlobal would make that particular variable declared within the flow a global variable but what about just put?
Additionally, what would the proper way to access the newly created variable from that flow be?

Thanks!
David

0 Likes
AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: Help with scriptlet

Jump to solution

put is adding the variable to the local context. a child flow with a put does not expose the variable to the parent. while a child flow with putGlobal, does.

you can access the variable with ${variablename}. You can see the variables in Studio in local and global contexts.

some examples are given here too: https://lnast01pcache.saas.hpe.com/asset/resources/pd/oo/21q1459952042/HPOO_UnderstandingExecutionOrderAndMore_Guide.pdf

Andrei Vasile Truta
0 Likes
David_Teh Respected Contributor.
Respected Contributor.

Re: Help with scriptlet

Jump to solution

Hi Andrei,

I'm trying to access the variable from the menu in the figure below.

 Capture.JPG

I have attached below the script which is supposed to put the variable and its value within this particular flow as per my understanding HP OO thus far.

Capture.JPG

It seems to me that my script may not be saving the variable correctly but I am at a loss as to what to do. I have also checked the Flow Variable tab but the variable that is supposed to be saved as part of the script does not appear. Any advice would be much appreaciated.

David

0 Likes
AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: Help with scriptlet

Jump to solution

You could to like this

Screenshot_44.pngScreenshot_45.pngScreenshot_46.png

Andrei Vasile Truta
David_Teh Respected Contributor.
Respected Contributor.

Re: Help with scriptlet

Jump to solution

Hi Andrei

Thanks for the help!

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.