- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 01:37 PM
Hi,
I am trying to use substring() function to extract a part of the variable value and pass it on the target record but it is not working. Actually, I want to remove the '$' sign from the value and take the rest of the string. I am able to pull the whole value but not a substring. Have tested by logging results in gs.log.
Can anyone please help?
Any help will be highly appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2018 07:56 AM
Just go with:
var capexSwCost = (producer.Software_CapEx_Cost.toString()).replace("$", "");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 01:41 PM
How about using the replace() method instead?
str = "$123.45";
str2 = str.replace("$", "");
would return "123.45"
Otherwise, what are you trying now, and what are the results?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 09:35 PM
Could you please share your code, what exactly you are trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2018 07:35 AM
Here is the code -
var CapexSwCost = producer.Software_CapEx_Cost;
var CapexSwCost1 = CapexSwCost.toString();
gs.log('CapEx SW Cost from RP in local substring var is ' + CapexSwCost1.substring(1)); // this line is showing the result as 'undefined'
gs.log('CapEx SW Cost from RP in local var is ' + CapexSwCost);
gs.log('CapEx SW Cost from RP in RP var is ' + producer.Software_CapEx_Cost);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2018 10:06 PM
Is the variable you are calling the substring() Method on of type string?
Maybe try variable.toString() prior to calling substring() if it is not