Summary:

When trying to set up an integration the set up failed at the apply customisations stage with the following error message in synchlog.xml:

com.sage.scrm.model.customisation.error.SageCustomisationProcessFailed: com.sage.scrm.model.metadata.error.SageEntityModificationException: com.sage.scrm.model.metadata.error.SageEntityModificationException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

com.sage.scrm.model.customisation.error.SageCustomisationProcessFailed: com.sage.scrm.model.metadata.error.SageEntityModificationException: com.sage.scrm.model.metadata.error.SageEntityModificationException: Grid must have valid view or table name in TargetTable (use setTargetTable)


Resolution:

The issues we addressed in this case were around customisations applied to CRM via components. There were some errors when applying these components to CRM which are flagged at install time and which affected the referential integrity of the metadata.

A component that was installed on the customer’s CRM system reported the following error:  
SageEntityModificationException: Grid must have valid view or table name in TargetTable (use setTargetTable)

This is the same error we were seeing in the log files when a sync was initialized.

To identify the above issue we ran the following query:

select cobj_TargetTable,CObj_UseEntity from Custom_screenobjects where CObj_TableId IN (select GriP_ScreenObjectsIDFK from Custom_Lists where (GriP_GridName like 'ss%' or GriP_GridName like 'vss%'))

We noticed that the following views that were referenced did not exist on the database:   vPersonPhoneList, vPersonEmailList, vCompanyPhoneList, vCompanyEmailList

The next error we encountered was:
SageEntityModificationException: You must associate CustomGridItem with a CustomEdit (use setCustomEdit)

To identify the areas this was occurring we ran the following query on the database:

select GriP_ColName,GriP_CustomEditsIDFK from Custom_Lists where (GriP_GridName like 'ss%' or GriP_GridName like 'vss%') and GriP_CustomEditsIDFK is null

We noticed that some of the GriP_CustomEditsIDFK were set to NULL which was causing the error. These rows need to be updated to reference a corresponding row on the Custom_Edits table e.g. phon_type on the Custom_Lists table should reference phon_type on the Custom_Edits table.