Summary:

Issues with orphaned linked records may result in null pointer exceptions when using a GCRM integration.

Symptoms:

The described issue was reported by a customer using Sage Murano. On starting a synch, no Account records would transfer.

 

The following error was logged to the scrm.log:

ERROR: 15-ene-2014 12:39:02.740 Due to processing errors UUID = 91625212-3850-486f-b228-15b5033d3243 will be removed from SyncSource response feed. java.lang.NullPointerException  
    at com.sage.scrm.model.sync.SyncSourceManager.getUserIdentifier(SyncSourceManager.java:2516)  
    at com.sage.scrm.model.sync.SyncSourceManager.createAndFillPayloadProperties(SyncSourceManager.java:2190)  
    at com.sage.scrm.model.sync.SyncSourceManager.createPayloadForEntity(SyncSourceManager.java:1650)  
    at com.sage.scrm.model.sync.SyncSourceManager.processChildResources(SyncSourceManager.java:2445)  
    at com.sage.scrm.model.sync.SyncSourceManager.getPayloadItems(SyncSourceManager.java:2338)  
    at com.sage.scrm.model.sync.SyncSourceManager.createPayloadForEntity(SyncSourceManager.java:1694)  
    at com.sage.scrm.model.sync.SyncSourceManager.generatePayload(SyncSourceManager.java:399)  
    at com.sage.scrm.model.sync.SyncSourceManager$$FastClassByCGLIB$$91c4d5b7.invoke(<generated>)  
    ...
    at com.sage.scrm.model.store.SyncSourceSDataStore.handleSubsequentRequest(SyncSourceSDataStore.java:581)  
    at com.sage.scrm.model.store.SyncSourceSDataStore.generateContent(SyncSourceSDataStore.java:337)  
    at com.sage.scrm.model.store.SyncSourceSDataStore.getData(SyncSourceSDataStore.java:241)  
    at com.sage.scrm.controller.AbstractSyncController.getModelAndView(AbstractSyncController.java:275)  
    at com.sage.scrm.controller.AbstractSyncController.requestAction(AbstractSyncController.java:218)  
    ...
    at com.sage.scrm.controller.util.AbstractSessionRequestFilter.doFilter(AbstractSessionRequestFilter.java:125)  
    ...
    at java.lang.Thread.run(Unknown Source)

 

Cause:

The issue was caused by the presence of orphaned SyncResource entries for the Address entity. These addresses were linked to a parent Account entity, but had been hard-deleted from the CRM database. On attempting to run a synch, an attempt was made to create a mapping between the address records and the synch resources for these addresses - since the addresses had been hard deleted, this resulted in a null pointer exception. We strongly recommend against hard-deleting data on the Sage CRM database, unless acting under specific instruction of Sage support personnel.

The issue was identified by checking the debug logs from the same time that the error occurred - activity could be seen on the Address, Account and SyncResource tables in the scrmSQL.log.

Resolution:

The issue was resolved by running the following SQL:

delete from SyncResource
where SyRS_SyncResourceID in  (
    select SyRS_SyncResourceID
    from SyncResource where SyRS_LocalEntityMappingID = (
        select GLEM_GCRMLocalEntityMappingID
        from GCRMLocalEntityMapping
        where GLEM_LocalEntityName = N'Address')
    )
    and SyRS_LocalEntityID not in (
             
        select Addr_AddressId from Address
    )

A generic script is available to clean the SyncResource entries; this should resolve similar issues on all entities. It can be downloaded using the link below:

 Download: CleanSyncResource script

Please note that these scripts have not been passed by QA, and care should be taken to test your data before attempting these fixes in a production environment.