- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 06:59 AM
Hi All,
I need to add double quotes to values in an array please help me on how to do that.
Example: var arr=["servicenow,community"];
I have an array like this but i need the array as var arr=["servicenow","community"]; via server script
Please tell me on how to solve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 07:42 AM
It looks like you have a value as a string but need to have multiple values instead.
You could try to split this string into multiple values before putting it in the array.
try this one
var someValue = "servicenow,community";
arr = someValue.split(',');
gs.print(arr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 02:23 AM
Hi Upender ,
I need to convert my script as
""+table+"'",""+query+""
Is it possible?
If not , is their any way to achieve it?
If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.
Thanks,
Vaibhav Nikam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 07:12 AM
Hi Shalani,
If array is like that arr=["servicenow,community"], means it is having only one element.
Then you can try as below
arr=["servicenow,community"]
gs.print(arr)
var arr1=arr[0].split(",");
gs.print(arr1)
Now arr1 become the array of two elements.
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 07:27 AM
No it dint work sorry!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 07:33 AM
It is working if you are getting an array with single element. You want to seperate it, below code is working.
If you are expecting something else then please elaborate more.
Run the below code in background script
arr=["servicenow,community"]
gs.print(arr+": "+arr.length)
var arr1=arr[0].split(",");
gs.print(arr1+": "+arr1.length)
Output:
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 12:45 PM
It is working if you are getting an array with single element. You want to seperate it, below code is working.
If you are expecting something else then please elaborate more.
Run the below code in background script
arr=["servicenow,community"]
gs.print(arr+": "+arr.length)
var arr1=arr[0].split(",");
gs.print(arr1+": "+arr1.length)
Output:
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta