Abort importing record coming from intune to servicenow based on value of managedDeviceOwnerType.

GudiyaYadav
Tera Contributor

Hello Community,

I am working on preventing the import of specific records from Microsoft Intune into ServiceNow when the u_manageddeviceownertype field is set to personal. As part of the RRobust Transform Engine (RTE) setup, I’ve added script to the Before Script in the associated Transform Definition to conditionally abort the import process for those records having manageddeviceownertype as personal.

Here’s the script I’ve implemented:

 (function(input, runId) {
 
 
     for (var i = 0; i < input.length; i++) {
        var items = input[i].payload.items;

        // Loop backwards to safely remove items while iterating
        for (var j = items.length - 1; j >= 0; j--) {
            var values = items[j].values;

            if (values.u_manageddeviceownertype && values.u_manageddeviceownertype.toLowerCase() === 'personal') {
                items.splice(j, 1); // Remove the item safely
            }
        }

        // Optional: log if any items were removed
        if (items.length === 0) {
            input[i].status = 'SKIPPED';
            input[i].reason = "All items had ownertype = 'personal', skipping payload.";
        }
    }

Unable to exclude those types of records.
It will be a great help, If anyone suggest the proper implementation to complete the requirement.
I do not have much knowledge on Robust Transform Map.

1 REPLY 1

Pratiksha
Mega Sage
Mega Sage

Try writing a before BR for target table. We tried to do what you are doing now. It did not work. BR Will work.