Monday, August 4, 2014

Generate Posts in Social Pane for Migrated Records

Hello,
Few days back we faced very interesting issue where the Posts (as shown in below sample screenshot) were NOT getting generated for the account records which were migrated from previous version of CRM 4.0/2011 to CRM 2013. We verified that Posts were configured as expected for the account entity under "Settings -> Post Configuration" but still they were not getting generated however they were working perfectly for any new account records created directly in CRM 2013.
After spending multiple cups of coffee and lots of papers balls in the trash (actually it took just 20 minutes. Hahaha..!J) to figure out the problem. What I did was directly opened the CRM database and started looking for the reference tables for generating Posts. I found that below six tables were regarding Posts entity and all stuffs you see in CRM for Posts are handled through these tables (shown in below image)
From the initial symptoms of the issue which showed that Posts don’t want to get generated for Existing Migrated Records but they were happy enough to be in for newly created records in CRM 2013. This immediately kicked me to think that there must be some Mr. X (in form of some table) which is stopping the Posts to take birth. I quickly analyzed all tables affected after you create a new CRM account record in 2013 and for those which were migrated back from the previous version of CRM. This result of the analysis for the affected tables made my whole lot of hard efforts (J) fruitful.
Solution:
Above result clearly pointed out that the records for Exiting Migrated Records were missing in “PostBase” and “PostRegardingBase” (since we didn’t have any comments/follow/likes other relevant tables were empty for both types of records). Looking into the structure for both the above tables, I quickly found that “PostBase” have a foreign key column for “PostRegardingBase” and Bang On!!! We found Mr. X JJJ
Mr. X = PostRegardingBase
I quickly generated a small script for Mr. X and inserted a reference record for one of my Existing Migrated account record and tried making some legitimate changes in relation to that account which ideally should generate a Post and Guess what…
Eureka!!! Posts started getting generated for all the new eligible actions done against the Existing Migrated Account Record.
So basically in our CRM 2013 system somehow the records were missing in “PostRegardingBase” for all migrated records for the entities and we just have to “Insert” those records into this table to start Posts taking into effect for migrated records. Below table will give you mapping for the data in columns for PostRegardingBase table. Below table shows values as per Account entity record but you can change it as per your needs for other entity.
Column Name
Data to be Inserted
PostRegardingId
NewID()  “New Guid”
RegardingObjectOwningBusinessUnit
BusinessUnitId for the account record.
RegardingObjectId
AccountId (Guid) for the account record.
RegardingObjectOwnerId
OwnerId for the account.
RegardingObjectTypeCodeForSharing
ObjectTypeCode for the Account i.e. 1
RegardingObjectOwnerIdType
ObjectTypeCode for the OwnerId type. For example User or Team.
RegardingObjectIdName
Account Name – Basically name field value of the record.
RegardingObjectTypeCode
ObjectTypeCode for the Account i.e. 1
RegardingObjectIdYomiName
NULL
LatestManualPostModifiedOn
NULL
LatestAutoPostModifiedOn
GetUTCDate() – Basically Current UTC Timestamp

Hope this post helps you! Feel free to provide your valuable comments/suggestions.
Thank You. Enjoy! J
Important Note:
  • Posts will start getting generated from ongoing basis.
  • Recommendation is to take care of this table during Data Migration Planning Phase itself so that along with all migrated records, their reference records will also be pushed to PostRegardingBase table.
  • Direct database operation is not recommended by Microsoft so please do this at your own risk with all necessary backups taken and after testing in Development environment.