The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Data Source Test Load 20 Records/Load all records Fails with error.

MuskanJ45326756
Tera Contributor

Hi Team,

 

We have Intune integration setup for updating 'Last Activity' field of Hardware table but when I am performing test load 20 records/Load all records on Intune Data source, I am getting error "Cannot invoke "org.apache.poi.hssf.usermodel.HSSFSheet.getLastRowNum()" because "this.fSheet" is null" due to which data is not getting transformed in Hardware table (before running test load it was working fine).

MuskanJ45326756_0-1739261603504.png

 

 

Currently, we have a REST API for last activity field and we are calling the REST API via schedule job. So, I have checked REST API and Schedule job and those are working fine. I can see the data flow is happening in staging table but transformation is not happening due to above error.

 

Have you encountered this before or aware about this issue in ServiceNow ?

 

Regards,

Muskan Jain

6 REPLIES 6

@MuskanJ45326756 

share the configurations screenshots in dev since you said it's an issue in DEV as well.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

MuskanJ45326756
Tera Contributor

Hi Ankur,

 

Intune is not in dev but we have it in test and prod.

Rest API - https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$select=lastSyncDateTime,deviceName...

 

Schedule job - 

try {
    var machines = [];

    function getMachines(endpoint, machines) {
        gs.info('in getMachines with endpoint: ' + endpoint);
        var pagedR = new sn_ws.RESTMessageV2('Intune for lastSync for workstation', 'Default GET'); // Replace the first parameter with the name of your REST message.
        if (endpoint !== null) {
            pagedR.setEndpoint(endpoint);
        }
        var pagedResponse = pagedR.execute();
        var pagedResponseBody = pagedResponse.getBody();
        var pagedhttpStatus = pagedResponse.getStatusCode();
        gs.info('windowsMachinelastsync response: ' + pagedResponseBody);
       gs.info('windowsMachinelastsync response Status: ' + pagedhttpStatus);
        var pagedObj = JSON.parse(pagedResponseBody);
       var newMachines = pagedObj.value.filter(function(device) {
            //This is the snippet that filters out only Windows devices. Hence the Windows only shceduled job.
            //if (device.operatingSystem != "Windows" || device.serialNumber != '' || device.serialNumber != '0' || operatingSystem != '')
           
            if (device.deviceName != ''){
                return true;
            } else {
                return false;
            }
        });  
        gs.info(endpoint + ' lastsync: ' + newMachines.length);
        machines = machines.concat(newMachines);
        if (pagedObj["@odata.nextLink"]) { // if it has paged results
            gs.info('iflastsyncmachines.length: ' + machines.length);
            getMachines(pagedObj["@odata.nextLink"], machines);
        } else {
            gs.info('lastsyncmachines.length: ' + machines.length);
            machines.forEach(function(machine) {
                gs.info('lastsyncin foreach');
                var intuneImport = new GlideRecord('u_intune_last_sync_devices'); // Replace with your Import set table name
                intuneImport.initialize();

                //Set each field in the table to the correct data from payload
                for (var key in machine) {
                    if (machine.hasOwnProperty(key)) {
                        gs.info('firstifmachine: ' + machines.length);
                        var field = key.toLowerCase();
                        var value = (function() {
                            if (typeof machine[key] === "number") {
                                gs.info('secondifmachine: ' + machine[key].toString());
                                return machine[key].toString();
                               
                            } else {
                                gs.info('thirdifmachine: ' + machine[key]);
                                return machine[key];
                            }
                        })()

                        var actualField = 'u_' + field;
                        if (intuneImport.isValidField(actualField)) {
                            gs.info('setting (short)[' + actualField + ']:' + value);
                            intuneImport.setValue(actualField, value);
                        } else {
                            var begin = field.substring(0, 12);
                            var end = field.substring(field.length - 14, field.length);
                            var calculatedField = 'u_' + begin + '_' + end;
                            gs.info('setting (long)[' + calculatedField + ']:' + value);
                            intuneImport.setValue(calculatedField, value);
                        }
                    }
                }

                intuneImport.insert();
                gs.info('fourthifmachine: ' + intuneImport);
            });
        }
    }

    getMachines(null, machines);
} catch (ex) {
    var message = ex.message;
    gs.info('Intune ERROR: ' + message);
}
 
 
Regards,
Muskan