Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

refresh BDC in code?

  Asked By: Bhavani    Date: Jul 29    Category: Sharepoint    Views: 2249

Anyone know how to refresh data for an entity using code? looking through the SDK I can't see how this is easily done. I need to update the data in an entity after changes to the data source, the functionality provided when users click the refresh icon next to the title of a business data column in a list is ideal for my purposes - just need to replicate in code....



1 Answer Found

Answer #1    Answered By: Eliza Hutchinson     Answered On: Jul 29

From this solution it is the SP list  that is triggering the refresh. Do you create this solely as a work around
to this problem or the list is there to serve other purposes?

The refresh  rates were quicker (instant!) compared to using database connection, but mostly I did this to serve other purposes. The list acts as a central store for the data  coming out of CRM and as the data source  for the BDC. This allows the data to be altered in the list, extra columns and info added to the data which isn't available in CRM, this data will then be passed on to the BDC. With the data source on the same server, the system also reduces the problem of any errors being thrown because the BDC can't access is data source, which sometimes happened when I tried connecting directly to the CRM database. By using some basic custom web services I was also able to remove any need to understand the schema for CRM databases and it will be easier to understand and extend in the future. The flip side is that there are more working parts to this solution so more components will need to be changed.

Would you be concerned that if there is a lot of database updates and SP list updates that there may be too many refreshes, especially if the BDC is used by many?

Not from the testing I’ve done, at the CRM end it isn’t possible for users  to make bulk changes or create new data in bulk like it is in a SharePoint list, even so we wrote code  to loop through and create a few hundred records and make changes to a few hundred records to see how this showed up at the other end and no problems. Changes went through to the central SharePoint list and were picked up by the BDC, even at this volume I saw the new and changed CRM data coming through to the business  data columns I’d setup in other lists within a few seconds. Note that I haven’t created anything to force refresh in the BDC, only relied on it’s default behaviour which I (eventually!) found to be very good – well optimized.

So have you found a way to get Business Data columns in Lists/Doc Libraries to refresh automatically (or at least programatically) without having to click  on the little refresh icon  above them?
Actually I forgot to point out that the critical thing for us was seeing new and changed data instantly available in business data column  lookups (the list that pops up when you click the address book next to the field when editing a list item). Updating existing data is still done by clicking the refresh icon, or as I found the data will update  the next time a user edits the list item anyway. We did look at this and figured the best way was to write a tool which we scheduled to run, that would look for all lists containing business data columns pointing to our LOB System and Entity and update the business data column and it’s secondary fields, but in the end decided not to go with this because it would change the Last Modified By and Last Modified Date columns every time the schedule ran and the effort wasn’t worth the payoff. By the way for those who haven’t already discovered this, if looking to make use of the business data field in code you can find them by looping through the fields in a list and looking for SPField.TypeDisplayName = “Business data” then cast this field to a Microsoft.Sharepoint.Portal.WebControls.BusinessDataField object. There are extra methods and props in this class which really help in quickly finding the data in BDC and updating the secondary fields (those hidden fields that are created when you use a Business Data column). If you decompile the code that's fired when users click the refresh icon, you'll see that this is the way MS do it.

Sorry that’s all a bit long winded but if you have any other questions let me know

Didn't find what you were looking for? Find more on refresh BDC in code? Or get search suggestion and latest updates.