Archive

Archive for January, 2012

Entities display area not getting set on Solution Import in CRM 2011

January 10, 2012 1 comment

Hi,

Please observe below scenario

  • In my CRM organization “ORG – A
  • I Created a new custom entity “new_city” and I set “Area to display” as “Workplace”.
  • I created a new “Managed” solution “Sol – I” having the custom entity “new_city”
  • Now In my Organization “ORG – B”, I imported the solution “Sol – I” successfully.

Issue I Faced :-

  • After solution import, to my surprise I don’t see entity “new_city” under “Workplace” area
  • To dig more, When I open “new_city” entitie’s customization form , all the options under “Area to display” are unchecked.
  • Since the solution was “Managed” I can’t select the  “Area to display” option manually.

Fix :-

  • While making the solution, Include “Sitemap component” under Client extensions

Hope it helps 🙂

Bulk Updating or Inserting records from Excel using CRM Data Import

January 8, 2012 1 comment

Hi,

In CRM, you may come across scenarios where you need to Update/Insert a very large number of records very quickly. In these cases, opening each record’s form to make the change can be time-consuming.

We can handle this better by using CRM Data Import feature by which we can make bulk Update/Insert very quickly.

Below are the steps to achieve this. I am using ‘Contact’ entity for this article.

Steps :-

  • Navigate to ‘Contact’ entity
  • Click on “Export to Excel” button in the Ribbon menu
  • In the “Export Data to Excel” dialog box which comes up, Select “Static worksheet with records” and check the “Make this data available…” check box.
Export Data to Excel Dialog Box

"Export Data to Excel" Dialog Box

  •   Save the file
  •  Open the Excel file and it looks as below
Records in imported file

Records in imported file

Important Points :-

* This Excel file has some unique characteristics which simplifies the data entry and re-import process.

* As you click on each cell, you will notice a pop-up that tells you format of the data and whether the field is required or not.

* Required fields are not enforced in Excel (i.e., Excel won’t validate even if you miss the value in required cell).

* If you miss a value in required field cell, the record wont be updated in the import process.

* You can enter “Lookup” values also, but the values must match with parent record.

For example, In this Excel “Parent Customer” cell is a lookup to the “Account” entity. So i need to give “Account” full name in the cell.

* If any wrong data entry in the lookup cell, the record will not be updated on import

  • In the imported Excel (Above screen), If you observe, I don’t have “Middle Name” for any of my contacts. So I am giving middle name as “Updated” (Below screen)
Updating "Middle Name" field

Updating "Middle Name" field

  •  Next, I want to insert a new record “Rajeev Pentyala” to my contacts.

          Important Point :-

– We can create new records by entering them in the bottom of Excel. (***Be sure to fill all required fields ***).

  • So, In my last row of Excel, I enter “First Name”,”Last Name” ,”Email”,”Parent Customer” (i.e.,Valid full name of existing Account)
Adding new record

Adding new record in the last row

  •  Save the Excel file. (Ignore the warning and continue saving)
Ignore warning and save

Ignore warning and save

  • In the CRM, Click on “Import Data” button in the Ribbon
  • In the dialog window browse the saved file
Import process

Import process

  • Click “Next” button
  • In the next window, click on “Submit” button
Import process - submit

Import process - submit

Import Porcess - Finish

Import Porcess - Finish

  • Refresh the CRM application
  • Now you can see the newly inserted contact “Rajeev Pentyala” with the given values in Excel
Import - New Contact

Import - New Contact

  • You can also verify the remaining contacts with the updated “Middle Name”
  • This is how we handle  “Data import” process

Tip :-

  • To verify your import finished successfully or any problems with it.
  • Navigate to “Settings -> Data Management -> Imports”
Data Import - Settings

Data Import - Settings

Imported File

Imported File - Success & Failures

This article provides you a basic knowledge about Data import from Excel.

Hope it helps 🙂

“The context is not currently tracking the entity” exception in CRM 2011

January 3, 2012 1 comment

Hi,

You may come across below exception when you are trying to Create/Update child record in the Parent record context of Plug-in using XRM Linq

Context is not currently tracking entity

Context is not currently tracking entity

Scenario :-

  • Imagine you have registered a “Post Update” Plug-in on ‘Account’ entity which Updates an associated ‘Contact’ entity
  • Here the Plug-in runs under Parent Entity Context (i.e., Account)
  • When you try to update child record (i.e.,Contact) it throws out exception, since the context knows nothing about ‘Contact’

Fix :-

  • The solution is call the context.Attach() method; Call this method before calling the Update method (Refer below code)

IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

var ServiceContext= new XrmServiceContext(service);

Guid contactGUID= (from c in xrm.ContactSet where c.FullName == “Farest Chand” select c.Id).FirstOrDefault();

ServiceContext.Contact objContact= new ServiceContext.Contact {  Id = contactGUID,  FullName= ‘Rajeev’};

ServiceContext.ClearChanges();

ServiceContext.Attach(objContact);

ServiceContext.UpdateObject(objContact);

ServiceContext.SaveChanges();

Hope it Helps 🙂