
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
12-13-2021 02:25 PM - edited 07-20-2025 12:10 PM
< Previous Article | Next Article > | |
Integrate with Microsoft Intune - Scripted Data Retrieval | Mapping data with RTE/IRE |
Introduction
Keeping with the times, IntegrationHub is immensely powerful in it's performance, easy maintainability and integral foundation as part of the NOW platform. Data can be retrieved using a flow data stream, however, this does require an Enterprise IntegrationHub license (check with your account manager) which does put it out of reach for a number of organisations.
Connection Alias
To use flow designer with the OAuth credential record we created earlier, a connection and credential alias has to be created.
- Search for Connection & Credential Aliases in the application navigator and create a new record
- Set a sensible name and a connection type of HTTP
- Save the record and create a new connection record via the related list
- Set the connection URL to https://graph.microsoft.com
- If you tested the credentials in the second article, you would have already created a credential record. If you didn't, use the magnifying glass to pop out the reference field table and create a new record. Select the OAuth entity profile created in the earlier article.
- Save the record
Create Data Stream Action
Creating a flow designer data stream couldn't be easier and hopefully, this article will help with some foundational knowledge. If you're wanting more of a background of data streams and a step by step of creating one, I recommend walking through this course Data Stream Actions Objectives | ServiceNow Developer
- Within Flow Designer select the new button and Data Stream. If you can't see an option for data stream, make sure you have the relevant plugins installed as documented in the introduction article to this series
- Give the data stream action a sensible name such as Get Intune Computers and save the record
Data Stream actions allow for large, paginated, response bodies by cycling through data retrieval based on a starting input and pagination variables.
- From the left, select Inputs and create two input records of type string. Label the first as nextLink and the second as base.
- Expand the inputs using the arrow toggle on the right.
- Set the nextLink default value to our query input of beta/deviceManagement/managedDevices?filter=deviceType eq 'desktop' or deviceType eq 'macMDM' or deviceType eq 'winEmbedded' or deviceType eq 'surfaceHub' or deviceType eq 'windowsRT'
- Set the base default value to https://graph.microsoft.com/
- Make sure both variables are mandatory and select save. It's important to remember that, unlike workflow, there isn't auto-saving so regular saves will prevent any data losses.
- Select the Request menu from the left navigator and set the data retrieval mechanism to REST Step and enable pagination
- Select Pagination Setup step and use the blue/green plus sign to the right of the form to create two new variables
- Copy the setup below into the variables
- Enter the following script into the script section
(function paginate(variables, pageResponse) {
if (!gs.nil(variables.nextLink)){
variables.nextLink = variables.nextLink.replace(variables.base, '');
variables.getNextPage = true;
} else {
variables.nextLink = "";
variables.getNextPage = false;
}
})(variables, pageResponse);
- Navigate to Rest Step and set the connection alias to the one created previously
- Set the resource path to the pagination setup step nextLink
- Select Parsing and set the two fields to JSON Splitter and Script Parsing respectively
- Under the splitter step, set the format to JSON and set the path to $.value
- In the script step, enter the script below. This maps the fields we want to keep from the managedDevice object returned by the Graph API
(function parse(inputs, outputs) {
var record = JSON.parse(inputs.sourceItem);
outputs.targetObject.id = record.id;
outputs.targetObject.userId = record.userId;
outputs.targetObject.deviceName = record.deviceName;
outputs.targetObject.enrolledDateTime = record.enrolledDateTime;
outputs.targetObject.operatingSystem = record.operatingSystem;
outputs.targetObject.complianceState = record.complianceState;
outputs.targetObject.osVersion = record.osVersion;
outputs.targetObject.emailAddress = record.emailAddress;
outputs.targetObject.model=record.model;
outputs.targetObject.manufacturer=record.manufacturer;
outputs.targetObject.serialNumber = record.serialNumber;
outputs.targetObject.wiFiMacAddress = record.wiFiMacAddress;
outputs.targetObject.managedDeviceOwnerType = record.managedDeviceOwnerType;
outputs.targetObject.jailBroken = record.jailBroken;
outputs.targetObject.userDisplayName = record.userDisplayName;
outputs.targetObject.deviceEnrollmentType = record.deviceEnrollmentType;
outputs.targetObject.managementAgent = record.managementAgent;
outputs.targetObject.totalStorageSpaceInBytes = record.totalStorageSpaceInBytes;
outputs.targetObject.deviceType = record.deviceType;
outputs.targetObject.freeStorageSpaceInBytes = record.freeStorageSpaceInBytes;
outputs.targetObject.ethernetMacAddress = record.ethernetMacAddress;
outputs.targetObject.chassisType = record.chassisType;
outputs.targetObject.userPrincipalName = record.userPrincipalName;
outputs.targetObject.connectionAliasId = inputs.fd_data.action_inputs.connectionalias.sys_id
})(inputs, outputs)
- Navigate to Outputs and select Edit Outputs
- Select Create Output with a label and name of targetObject and type of Object
- Use the small plus option to add properties to the object. For each output line in the script, a relating property has to be created in the data stream output. This is unfortunately a repetitive process and the important thing is to ensure the name of the property matches that of the name in the script.
- Save the data stream and test it
- In the execution details, you should see something similar to the below
Create Data Source
The data stream action provides the mechanism to retrieve the data we want, we now need to create the data source that'll take the retrieved data and store it within a staging table ready for transformation.
- Navigate to System Import Sets via the application navigator and create a new data source
- Set a name to identify the source, i.e Intune Computer Devices
- Set a label for the table the system will create for us, i.e Intune Computer Devices IMP
- Set the type to Data Stream
- Check Data in single column
- Select your data stream action. If your action isn't visible, make sure it's set to published.
- Save the record and use the Test Load 20 Records UI Action to pull some example data.
- 4,596 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Question, do you mind sharing how to bring in more than 1000 records from Intune using what we've learned here?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
We've encountered a limitation of what the API is able to return when you query all devices at once. The “hardwareinformation” body response, which contains the “ipaddressv4,” field comes back as “null” when you pull all devices. However, if you specifically query the device using its device ID and you include a $select parameter for that field, then it returns the value(s).
This is a known workflow limitation as of May 2022 that Microsoft is allegedly planning to streamline; Source: Microsoft Graph Api - Physical Memory Info for Managed Devices is not being returned correctly. - Mi...
Is it possible to incorporate a follow-up query? Example:
- After we identify all the items like 'ipaddressv4' that return null and decide which ones we absolutely want. Store those fields in a “$select=hardwareinformation,…” parameter.
- For each device, run a follow-up query targeting the deviceID, and collect those fields using the $select parameter.
If not, is there one endpoint query I can be used for the REST integration, that can bring in all the devices along with their IP addresses (and installed software and running processes)? Perhaps a concatenated endpoint query?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello @Kieran Anson ,
Thank you for your post it was really helpful. I followed all of it to get at least some results.
However, i am struck with the issue where the nextLink is not getting updated after the first time with the newer ones. And thus, even if the ['@odata.count'] is around 7000 it is going in a never-ending loop. My offset is set as 999 from $top parameter within the url.
Do you have any inputs for me?
Regards,
Shariq

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hey Kieran,
I stumbled upon this article by accident, great read by the way 👍, and thought you should know that the links in the beginning pointing to the previous/next piece of the article series isn't working.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I'm getting a weird error during the Request Stage > Rest Step:
All the fields are grayed out and un-editable. I was able to add the Connection Alias using the search button, however I can not modify the Request Details step.
Then in Parsing > Script Parser Step: I do not see the area to "Under the splitter step, set the format to JSON and set the path to $.value"
Please help 🙂 Great article super hopeful I can use this!

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I had to delete the connection and associated steps since it was also greyed out then recreate it. Select None and then Rest Step. Make sure you select the correct options and checkboxes else you cannot go back once saved.
Make sure you select the correct options and checkboxes else you cannot go back once saved.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Nathan Okh
I am also seeing this issue and the only way I could find to update it was do delete the Rest step and recreate it. Make sure to take a backup copy of the action to refer to for the details and scripts. This appears to be a new issue since I wasn't seeing this previously.
If you choose None and save as above you can select Rest and tick the box then re-enter the connection details.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
We are experiencing the same issue/question as Nathan Okh

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Chris Cardenas @Nathan Okh I was able to apply a workaround. This involves deleting the rest step completely and recreating all the additionalsteps. Unfortunately this is not very elegant but resolves the issue.
Please let me know if you have any problems and I will post some screenshots. I tried to post but failed to.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I figured out the solution to my issue @Chris Cardenas @ConradJ, simply my plugin was not activated on ServiceNow Support... you'll need to search Activate Plugin... ServiceNow IntegrationHub Starter... It's also in the homepage of the plugin manager, and the like magic its there...
Documentation: https://docs.servicenow.com/bundle/utah-integrate-applications/page/administer/integrationhub/refer...

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks @snowolper I couldn't find the ServiceNow IntegrationHub Starter Plugin on our Dev platform but was able to request installation from the Support/Hi portal. It was however showing as available but not installed on our Production instance. This has fixed the issue for us, IIRC this used to work fine previously without this plugin.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
What options are there if you don't have the Enterprise IntegrationHub license and data stream?
Thanks