- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:15 AM
Hi All,
I have the below code but its not working as expected. I am storing few numbers in RITM description and wanted to obtain the max number.
----------------
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 11:21 AM
Forcing the retrieved description to a string should remedy that
var descArr = gr.description.toString().split(',');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 09:19 AM
gr.description might be a string field. Try below code in the while loop:
ritmAT.push(parseInt(gr.description)); //101, 102
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 09:57 AM
Still showing NaN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 10:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 11:44 AM
// Make sure you're getting the description, split desc on comma, then reduce array (allows parsing of string to int).
var desc = '101, 102';
var descNums = desc.split(',');
var max = descNums.reduce(function(a, c) {
return Math.max(parseInt(a), parseInt(c));
}, descNums[0]);
gs.info('max='+max);