- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 07:22 AM
I am writing a 'Script Action' to respond to event 'session.established'. In this script action, I am trying to use the basic javascript function split(), but the function is not producing an array as expected. Below is my script:
setOnNetwork();
function setOnNetwork() {
//get the current session IP address
var ipAddress = gs.getSession().getClientIP().toString();
gs.log('Script Action - Set OnNetwork Session Value: ' + ipAddress);
//split the ip address by period
var ipSplit = ipAddress.split(".");
gs.log('Script Action - Set OnNetwork Session Value: ' + ipSplit[0]);
gs.log('Script Action - Set OnNetwork Session Value: ' + ipSplit[1]);
gs.log('Script Action - Set OnNetwork Session Value: ' + ipSplit[2]);
gs.log('Script Action - Set OnNetwork Session Value: ' + ipSplit[3]);
}
Here are the resulting log messages:
Information | Script Action - Set OnNetwork Session Value: 192.189.129.17 |
Information | Script Action - Set OnNetwork Session Value: undefined |
Information | Script Action - Set OnNetwork Session Value: undefined |
Information | Script Action - Set OnNetwork Session Value: undefined |
Information | Script Action - Set OnNetwork Session Value: undefined |
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 07:41 AM
Looks like it's not actually getting set to a string. Try this instead on line 4:
var ipAddress = gs.getSession().getClientIP() + '';
I tested in an instance and that seemed to work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 07:41 AM
Looks like it's not actually getting set to a string. Try this instead on line 4:
var ipAddress = gs.getSession().getClientIP() + '';
I tested in an instance and that seemed to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2017 07:50 AM
Thank you! Very strange. So, that means the toString() function is actually what isn't working. While your suggestion works, I wonder what impact that will have on the rest of the scripts I have out there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 07:05 AM
I was struggling with this issue from an hour... Thanks Brad, it helped a lot