SCCM Import fails due to future last run datetime

MGanon
Tera Guru

Our SCCM import fails because the last run datetime updates to a date far into the future. The last run database field is LastHWScan. We can use the import table to identify the server(s) with the future date but we don't want to constantly monitor the integration to identify that the date is set incorrectly. I don't want to write a Business Rule to reset the date if there is a better way. Is there a more automated method? 

1 ACCEPTED SOLUTION

Andrew Westerv4
Mega Guru

A Business Rule to "reset" the Last Run Datetime is pretty much the only way I've found a way around this. Below is my example Business Rule on the Data Source table, you may need to update the category to which ever SCCM version you are using. The script will look to see if the date is after today, and if so it will reset it to today at midnight.

 

Condition: current.last_run_datetime.changes() && current.category=='SCCM 2012 v2 Integration'

Script:

var t = current.last_run_datetime;
var tFormat= t.replace(/'/g,"");
var gdtSCCM = new GlideDateTime(tFormat).getDate();
var gdtNow = new GlideDateTime().getDate();

if (gdtNow.compareTo(gdtSCCM) < 0 || t == ""){
t = "'"+ gdtNow.getDate().toString() +" 00:00:00.0'";
}

current.last_run_datetime = t;

View solution in original post

6 REPLIES 6

Nasir1
Tera Expert

Quite a bit late to the party but I encountered similar issue, and instead of going down the path of setting field value via business rule, I updated the SQL Statement that brings the computer records from SCCM DB, the idea is before importing look at each record and check if the LastHWScan is > NowDate, if yes then update the date to today's date.

I am adding the SQL statement here in case someone else needs it 
So remove the line v_GS_WORKSTATION_STATUS.LastHWScan,  and update it with the CASE statement

CASE
        WHEN v_GS_WORKSTATION_STATUS.LastHWScan > GETDATE() THEN GETDATE()
        ELSE v_GS_WORKSTATION_STATUS.LastHWScan
 END AS LastHWScan,





KRafi
Tera Contributor

Hello,

I understood that ServiceNow will do only delta imports based on the LAST RUN DATE TIME.

But is there a way to handle deletions of CIs?

We have an issue where CIs are being removed in SCCM but the information is not being updated/removed in SCCM?
What are the best practices to handle the deletions?