Import Set - 'Loading'

kchorny
Tera Guru

I am having the issue described in this thread

https://community.servicenow.com/community?id=community_question&sys_id=8b9fcf25dbdcdbc01dcaf3231f96196d&view_source=searchResult

in that I have some import sets that are continually 'Loading' well after all of the rows have been created and sometimes indefinitely. 

That thread indicates that the issue is in the script that creates the import rows. 

Is there something I can add to my script that will tell the import set to know it's done loading? Why doesn't it already know that?

Here is an example of one of the jobs where this happens consistently:

gs.info("VMWare: VMWare Data Pull Script [Started]");
GetVMWareMobileDevices();
gs.info("VMWare: Data Pull Script [Complete]");


function GetVMWareMobileDevices() {
    try {
        // Setup the REST connection, execute that request and capture the 
        // response and status
        var r = new sn_ws.RESTMessageV2('VMware', 'Default GET');
        var response = r.executeAsync();
	//response.waitForResponse(120);//wait 120 seconds for response - only use this if glide.http.outbound.max_timeout.enabled = false
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();

        // Initialize the XML document so we can parse the data
        var xmldoc = new XMLDocument(responseBody);
        var nodelist = xmldoc.getNodes("//DeviceSearchResult/*");

        // Grab the number of nodes (devices) that were returned
        // by the inquiry
 	var id_list_length = nodelist.getLength();

        // Setup our list of counters to keep track of our iterations
        var counter = 0;
        var total_it = 0;

        // Walk through each of the devices to get the specifics
        for (var i = 0; i < id_list_length; i++) {
            counter++; // Used to keep track of which node in the list we are on.
            total_it++; // This tells us how many times we iterated through

            // Assign the variables using the data we collected
            // This is done using XPATH operations to walk the structure
            // and capture the specific XML node(s) we need
            var vmware_id = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/Id");
            var serialnumber = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/SerialNumber");
            var assetnumber = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/AssetNumber");
            var devicefriendlyname = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/DeviceFriendlyName");
            var devicereportedname = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/DeviceReportedName");
            var locationgroupid = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/LocationGroupId");
            var model = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/Model");
            var platform = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/Platform");
            var phonenumber = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/PhoneNumber");
            var os = xmldoc.getNodeText("//DeviceSearchResult/Devices[" + i + "]/OperatingSystem");
            var gr = new GlideRecord('u_vmware_mobile_devices');

            // With the data capatured it needs to be written to the 
            // table and committed
            try {
                gr.initialize(); // Initialize the table for the insert
                // Assign variables to the table columns
                gr.u_vmware_id = vmware_id;
                gr.u_asset_number = assetnumber;
                gr.u_serial_number = serialnumber;
                gr.u_device_friendly_name = devicefriendlyname;
                gr.u_device_reported_name = devicereportedname;
                gr.u_location_group_id = locationgroupid;
                gr.u_model = model;
                gr.u_platform = platform;
                gr.u_phone_number = phonenumber;
                gr.u_operating_system = os;
                gr.insert(); // Insert the record
            } catch (ex) {
                // If there is an error during the insert we need to raise that to the logs
                // for troubleshooting 
                var insert_message = ex.message;
                gs.warn("VMWare Mobile Device Insert Error: " + insert_message);
            }

        }
        // If there is an error when trying to connect to the REST Web Service
        // it should be raised in the logs for troubleshooting
    } catch (ex) {
        var message = ex.message;
        gs.warn("VMWare Data Pull Error (Web Service Call): " + message);
    }
}
1 ACCEPTED SOLUTION

Yousaf
Giga Sage

Hi Kchorny,

Could this be related to your issue

find_real_file.png 
Reference : Synchronous Import Sets Remain in 'Loading' State


Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

View solution in original post

3 REPLIES 3

Yousaf
Giga Sage

Hi Kchorny,

Could this be related to your issue

find_real_file.png 
Reference : Synchronous Import Sets Remain in 'Loading' State


Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

Thank you, this explains a lot!

No problem. Glad it helped.


***Mark Correct or Helpful if it helps.***