How to split the sys_id in a array

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 01:08 AM
Suppose I am having a array variable which contains
c3482d26dba57010255c0febd39619b1e504a24bdbb6b4d00a66cf2414961973eac3e28b1bbaf4d0c8f487bbe54bcbc1
The above is a combination of three sys_id I need to split them after every 32 digits and store in the array
Thanks in Advance
Utsav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 01:25 AM - edited 11-03-2023 01:29 AM
Hi @Utsav JAISWAL
Can you try below logic :
var array = "c3482d26dba57010255c0febd39619b1e504a24bdbb6b4d00a66cf2414961973eac3e28b1bbaf4d0c8f487bbe54bcbc1";
var newArray = [];
while (array.length) {
newArray.push(array.substr(0, 32)); //updated
array = array.substr(32);
}
//gs.print(newArray);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 01:33 AM
So, if I want to get the output as ['b60426cb1bbaf4d0819396433b4bcb3e', 'e504a24bdbb6b4d00a66cf2414961973','eac3e28b1bbaf4d0c8f487bbe54bcbc1']
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 01:39 AM
Yes...the second line "newArray" stores the result as you mention like ['b60426cb1bbaf4d0819396433b4bcb3e', 'e504a24bdbb6b4d00a66cf2414961973','eac3e28b1bbaf4d0c8f487bbe54bcbc1']
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates