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


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(  
    at com.sage.scrm.model.sync.SyncSourceManager.createAndFillPayloadProperties(  
    at com.sage.scrm.model.sync.SyncSourceManager.createPayloadForEntity(  
    at com.sage.scrm.model.sync.SyncSourceManager.processChildResources(  
    at com.sage.scrm.model.sync.SyncSourceManager.getPayloadItems(  
    at com.sage.scrm.model.sync.SyncSourceManager.createPayloadForEntity(  
    at com.sage.scrm.model.sync.SyncSourceManager.generatePayload(  
    at com.sage.scrm.model.sync.SyncSourceManager$$FastClassByCGLIB$$91c4d5b7.invoke(<generated>)  
    at com.sage.scrm.controller.AbstractSyncController.getModelAndView(  
    at com.sage.scrm.controller.AbstractSyncController.requestAction(  
    at com.sage.scrm.controller.util.AbstractSessionRequestFilter.doFilter(  
    at Source)



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.


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.