- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 08:06 AM
Hi,
We have a multiline field on a item which we need to split into the indvidual lines and process these in a JS Script.
Is it possible to convert the multiline into an array, we have tried lines.split ('\n'); and also using match but neither have worked.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 09:19 AM
I use this in a recent bit of code. reads a multiline variable.
strUserList = srigr.variables.user_list.toString();
arrUsers=strUserList.match(/[^\r\n]+/g);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 09:40 AM
First convert your variable into a string by changing the first line:
var mylines = '' + current.variables.myLines;
This should work. I tested it out in my instance and it was failing to do anything until this was converted to a string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 09:19 AM
I use this in a recent bit of code. reads a multiline variable.
strUserList = srigr.variables.user_list.toString();
arrUsers=strUserList.match(/[^\r\n]+/g);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2015 12:14 AM
Julian that is perfect, I hadn't passed the field toString(); which is why this had failed in the past.
Thanks for your help you are a life saver.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2015 02:05 PM
Keep in mind that sometimes toString() is not an available function, depending on the object type. In these cases you'll either want to use Stacey's suggestion of var mylines = '' + current.variables.myLines; or a direct string conversion with var mylines = String(current.variables.myLines); - Personally I like to use the latter one whenever I want to reliably get a string.
Mike