- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 07:32 AM - edited 05-09-2023 07:38 AM
Hi
I have an issue when importing data from Intune where the IMEI imports as:
Primary:33445566778899,CTSubscriptionSlotTwo:11223344556677
I want to show just the first IMEI EG 33448866778899
I am using the following script but this only splits by the : and give a value of:
33445566778899,CTSubscriptionSlotTwo
Please could you advise what is missing from the script to remove all noise and just show the first IMEI .
I have added a comma as so .split(':,'); but this just give the original value without any splits
answer = (function transformEntry(source) {
var imei = source.u_imei.toString().split(':');
if (imei.length == 1) {
return imei[0];
} else {
return imei[1];
}
})(source);
Any help would be most appreciated
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 08:02 AM
@Adam Wood Here is the updated script.
answer = (function transformEntry(source) {
var imei = source.u_imei.toString().split(',')[0].split(':')[1]);
return imei; //Will return 33445566778899
})(source);
Please mark this answer correct and helpful if it manages to address your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 08:02 AM
@Adam Wood Here is the updated script.
answer = (function transformEntry(source) {
var imei = source.u_imei.toString().split(',')[0].split(':')[1]);
return imei; //Will return 33445566778899
})(source);
Please mark this answer correct and helpful if it manages to address your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 08:08 AM
Hi,
Here's an example to get what I believe you want.
var testStr = "Primary:33445566778899,CTSubscriptionSlotTwo:11223344556677"
var strArray = testStr.split(',');
gs.info("First is: " + strArray[0] + ". Second is: " + strArray[1]);
var strValueArray = strArray[0].split(':');
gs.info("First value is: " + strValueArray[1]);
which results in:
*** Script: First is: Primary:33445566778899. Second is: CTSubscriptionSlotTwo:11223344556677
*** Script: First value is: 33445566778899