Array returning unexpected result with addition ","
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 10:51 PM - edited 07-14-2025 10:53 PM
Hi Folks,
I have defined few arrays which i am later storing into a field (,) separated this is almost achieved but getting extra "," before the value
Current result:
MFP - ,MC,GS,L6,G8,4L,C5,9C,IT,E0,
,BWC - ,MA,8A,6A,R4,4M,4X,PQ,LE,
,Consumer Printer (HPS) - ,L9,LG,E4,IR,2Q,
expected result:
MFP - MC,GS,L6,G8,4L,C5,9C,IT,E0
BWC - MA,8A,6A,R4,4M,4X,PQ,LE
Consumer Printer (HPS) - L9,LG,E4,IR,2Q
Note : MFP , BWC , Consumer Printer (HPS) these are Business area which has associated PL keys which are MC,GS,L6,G8,4L,C5,9C,IT,E0, or MA,8A,6A,R4,4M,4X,PQ,LE,
i am calling Script Include from on change client script, below is the SI:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 11:35 PM
yes
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 12:35 AM - edited 07-15-2025 12:37 AM
it didn't work @Ankur Bawiskar
i think below line is causing the issue
return plKeys.join(',');
I have 16 records for "Notebook" which has diff PL Key values and same with "Desktop" hence i need below result
Notebook - G7,8N,TA,MP,AN
Desktops - GA,UT,I1,DG,US,BO,IL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 01:18 AM
What result are you getting now with the provided script ?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 02:45 AM
@Shraddha Kadam Set function won't work in Servicenow, I tried that already and Array.from also gave the same result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 04:52 AM
Hi @Ankur Bawiskar I have updated the same function but it has solved that additional"," issue but still not getting expected result.
currently i am trying with "pl.addQuery("india_classification", 'Notebook');" on var pl = new GlideRecord("x_ihpp2_sup_scoped_sup_product_mapping"); and getting below result, it should not add the same KEY to Desktops because i have not user Desktops in condition.
Notebook - G7,8N,TA,MP,AN,M1,8J,GB,6U,IK,UV
Desktops - G7,8N,TA,MP,AN,M1,8J,GB,6U,IK,UV
however i need to use dynamic condition like "