Highlighted
New Member.
288 views

how do you pass a Global list variable or Array variable to a Javascript and use it there?

how do you pass a Global list variable or Array variable to a Javascript and use it there?

 

it's urgent please...

0 Likes
4 Replies
Highlighted
New Member.

Re: how do you pass a Global list variable or Array variable to a Javascript and use it there?

is there any other way apart from passing it as String?

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: how do you pass a Global list variable or Array variable to a Javascript and use it there?

I'm not sure I understand the question.

 

Service Manager -type variables are always available to Javascript.  Just like any variables, they are bound by the type of variable - local, global, thread - and are only accessible while they exist.  A global variable (one that starts with $G) is always available, so Javascript can always access it.

 

Let's say you have a variable created via a global list - like the Incident Status ($G.incident.status) array of possible Incident statuses.

 

To access that variable in Javascript, you'd use

 

vars.$G_incident_status

 

That's an array in HPSM, and the tool handles the translation of that HPSM array to a Javascript array.  In Javascript, an array's position starts at 0, and in HPSM, it starts at 1, so 1 in $G.incident.status is the same as vars.$G_incident_status[0] in a Javascript

 

So there's nothing special that needs to be done.

0 Likes
Highlighted
New Member.

Re: how do you pass a Global list variable or Array variable to a Javascript and use it there?

Hi Jacob,

thanks for your reply.

 

In my case, the Javascript is called from the Scheduler. At that time, the Global varaible $G_xxx_xxx is having NULL value though I'm not clearing this variable.

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: how do you pass a Global list variable or Array variable to a Javascript and use it there?

Hmm... In that case, you need to hunt down where and how that global variable is being created.

 

For example, if you take a look at the login.DEFAULT formatctrl record, several $lo and $G variables are generated when a user logs in.  A background scheduler doesn't actually log in, so a variable like that won't exist for that scheduler. 

 

Other variables get created as the server starts up and regenerate periodically based on the global lister, so if you have a global list that you generated after you started the server, it's possible that, since it didn't exist when the scheduler started, the scheduler hasn't gotten an updated value for that variable.  In that case, you can use the System Status to kill the background process, and then restart it (or let anubis restart it, if it's one that generates on startup).  Then, it can grab the current value of the $G from the lister.

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.