In the DataSync Agent, you can truncate and delete all the records for a selected table in your database before bulk sharing. This is best for when you want to avoid using business rules to capture your deletes. Instead, you can use bulk share with Truncate Before Share enabled to send a message to the agent that will indicate a delete in all the records in the specified table. 

For tables like 

For example, 

  • For example, for tables cmdb_rel_ci, they get rebuilt nightly through discovery, you can use this feature to keep track
  • For tables like that where we cant capture deletes since they’re done silently, it allows you to be up to date
  • Runs discovery -> clears out table and recreates relations in the table -> so now the database needs to get in sync
  • To reflect to be accurate

This feature requires configuration in both the DataSync Agent and the DataSync application in ServiceNow. 

(info) NOTE: This is an advanced feature that will delete data from your database and should be used with caution. Incorrect use of this feature may result in data being lost that cannot be recovered. Contact Perspectium Support with any questions before enabling this feature.


Prerequisites


(warning) Stop running your DataSync Agent before making any Agent configuration changes.


Procedure

To truncate records for your DataSync integration, follow these steps:


Access your agent.xml configuration file

Navigate to the directory where you saved your agent.xml file when installing your DataSync Agent.

Add the truncate_table directive

Open your agent.xml file in a text editing application. Then, locate the <task> directive(s) and add <truncate_table>true</truncate_table>. 

Save your agent.xml

Save the changes you've made to your agent.xml and close the file. Your agent.xml should look similar to the example shown below:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
   <agent>
      <share/>
      <subscribe>
         <task instances="1">
            <task_name>datasyncforservicenow_to_mysql_subscribe</task_name>
            <message_connection password="encrypted:vlOtU71yu8N/EFIJH85SSBtaIt7qEEfvqiqft9VZyYE=" queue="psp.out.replicator.testqueue" user="admin">https://testperspectium.net</message_connection>
            <instance_connection password="encrypted:vlOtU71yu8N/EFIJH85SSPN9aF0P5/YViVwPEVFcGW4=" user="test.user">https://myinstance.service-now.com</instance_connection>
            <handler>com.perspectium.replicator.sql.SQLSubscriber</handler>
            <decryption_key>The cow jumped over the moon</decryption_key>
            <database_type>mysql</database_type>
            <database_server>localhost</database_server>
            <database_port>3306</database_port>
            <database_user>root</database_user>
            <database_password>encrypted:vlOtU71yu8N/EFIJH85SSMoilKLTeJHQrNZPJ7c5tFU=</database_password>
            <database_parms>characterEncoding=UTF-8 & useSSL=false</database_parms>
            <database_column_max_size>251</database_column_max_size>
            <database>psp_repl</database>
            <truncate_table>true</truncate_table>
         </task>
      </subscribe>
      <max_reads_per_connect>4000</max_reads_per_connect>
      <polling_interval>5</polling_interval>
      <skip_message_set_processing/>
   </agent>
</config>

Run your Agent

After configuring your agent.xml file, start running your DataSync Agent.

Create a ServiceNow bulk share

Follow the steps without executing the bulk share. 

Enable Truncate Before Share 

Under the Related Links, click Advanced view to access the Advanced tab. 

In the Advanced tab, check Truncate Before Share

Execute your bulk share

Click the Save button at the bottom of the form to save the configurations for your bulk share. Once your bulk share configurations have been saved, you can click back into the bulk share record and click the Execute Now button at the bottom of the form to bulk share out the specified records immediately.