
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2010 03:03 PM
Does the slice or substring functions not work on catalog task advanced scripts?
I would think this would work. Mark.Stranger has directed people to use it in a script in another forum topic.
I need to get the get the first three characters of a variable from a requested item. I can return the who result, but I cannot modify the answer, it just gives me undefined.
I tried this on the demo site, I can reproduce it there.
Okay, the set up, a field that has at least three characters in it. I looked for an item with a small text field, iPhone 3g, it has a small text field for the original phone number but has no rules to make it numbers, great!
That's known as current.variable_pool.original.
I looked to see if the item had a workflow, it didn't. So I changed the item to have the workflow, Service Catalog Item Request.
I went into the workflow editor and checked this out, added a catalog task to the start that used the advanced script. Below it is;
task.description = "Test\n";
task.description += "current.variable_pool.original: " + current.variable_pool.original + "\n";
task.description += "current.variable_pool.original.substring(0,3): " + current.variable_pool.original.substring(0,3) + "\n";
task.description += "current.variable_pool.original.slice(0,3): " + current.variable_pool.original.slice(0,3) + "\n";
All of these should work however, my result when the number is "abcdef" is below;
Test
current.variable_pool.original: abcdef
current.variable_pool.original.substring(0,3): undefined
current.variable_pool.original.slice(0,3): undefined
I know it will be a new copy tomorrow, but now you know what I'm doing, any thoughts on another way to accomplish this. I don't want to change the values of the variables as they are in a dropdown and the full text of it looks better than an abbreviation.
Here's a link to task in demo
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2010 07:22 PM
Try this. You need to force the variable value to be a string...
var orig = current.variable_pool.original.toString();
task.description = "Test\n";
task.description += "current.variable_pool.original: " + current.variable_pool.original + "\n";
task.description += "current.variable_pool.original.toString();substring(0,3): " + current.variable_pool.original.toString().substring(0,3) + "\n";
task.description += "orig.slice(0,3): " + orig.slice(0,3) + "\n";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2010 07:22 PM
Try this. You need to force the variable value to be a string...
var orig = current.variable_pool.original.toString();
task.description = "Test\n";
task.description += "current.variable_pool.original: " + current.variable_pool.original + "\n";
task.description += "current.variable_pool.original.toString();substring(0,3): " + current.variable_pool.original.toString().substring(0,3) + "\n";
task.description += "orig.slice(0,3): " + orig.slice(0,3) + "\n";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2010 01:11 AM
I knew it was something simply. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2017 12:16 AM
It helped me, Thank you .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 04:51 AM
Thanks a lot 🙂