diff --git a/nautobot_ssot/integrations/servicenow/jobs.py b/nautobot_ssot/integrations/servicenow/jobs.py index 5017d4f9..c3e5a175 100644 --- a/nautobot_ssot/integrations/servicenow/jobs.py +++ b/nautobot_ssot/integrations/servicenow/jobs.py @@ -1,5 +1,6 @@ """ServiceNow Data Target Job.""" +from diffsync.enum import DiffSyncFlags from django.core.exceptions import ObjectDoesNotExist from django.templatetags.static import static from django.urls import reverse @@ -21,8 +22,7 @@ class ServiceNowDataTarget(DataTarget, Job): # pylint: disable=abstract-method debug = BooleanVar(description="Enable for more verbose logging.") - # TODO: Implement or remove - # delete_records = BooleanVar(description="Delete synced records from ServiceNow if not present in Nautobot") + delete_records = BooleanVar(description="Delete synced records from ServiceNow if not present in Nautobot") site_filter = ObjectVar( description="Only sync records belonging to a single Site.", @@ -80,11 +80,14 @@ def load_target_adapter(self): self.target_adapter = ServiceNowDiffSync(client=snc, job=self, sync=self.sync, site_filter=self.site_filter) self.target_adapter.load() - def run(self, dryrun, memory_profiling, site_filter, *args, **kwargs): # pylint:disable=arguments-differ + def run(self, dryrun, memory_profiling, delete_records, site_filter, *args, **kwargs): # pylint:disable=arguments-differ """Run sync.""" self.dryrun = dryrun self.memory_profiling = memory_profiling self.site_filter = site_filter + self.delete_records = delete_records + if not self.delete_records: + self.diffsync_flags |= DiffSyncFlags.SKIP_UNMATCHED_DST super().run(dryrun, memory_profiling, *args, **kwargs) def lookup_object(self, model_name, unique_id):