Setting records to "active = false" if UPN value is not in import set

alexlwm
Giga Expert

Hi guys,

We are currently having an scheduled job running to import all of our shared mailboxes from a CSV on our mid server. When a new mailbox is created in O365, it automatically adds it in Servicenow.

The thing is, when a mailbox is deleted in O365, it still exists in ServiceNow. So i think i should create a transform map script to set the records to "not active" when the record is not available in the import set.

Does anyone has a solution for this one? I have tried various scripts with no results and you guys are my last resort

Thanks, Alex

1 ACCEPTED SOLUTION

Mihir Mohanta
Kilo Sage

1.You can write a on start transform script to make all records active false.


2.Then map the active field of the target table like it will set true for the available records which are coming from data source.



Thanks,


Mihir


View solution in original post

3 REPLIES 3

avinash kumar
Tera Expert

Hi Alex,



We are doing similar thing with the user records coming from LDAP.



var gr = new GlideRecord('sys_user');


  gr.addQuery('source','!=','');


  gr.addQuery('active','true');


  gr.addQuery('u_last_refresh','!=','');


  gr.query();


  while(gr.next()){


  gr.active = false;


  gr.update();


  }


     



In this code, we are checking if the LDAP import has run and then checking all the users whose record has not come and disabling them.



This can be done in POST SCRIPT of a scheduled job and you need to select enable post import script.



Basically this solution works fine if we are using a scheduled job. What are you using by the way?



Regards,


Avinash


Mihir Mohanta
Kilo Sage

1.You can write a on start transform script to make all records active false.


2.Then map the active field of the target table like it will set true for the available records which are coming from data source.



Thanks,


Mihir


Thanks Mihir,



Your solution was the easiest to implement. Thabks for your solution.



Thanks, Alex