Tuesday, December 30, 2008

CRM Online - InitializeEx() failed.

I created an ASP.net form and I tried to post the form data to CRM via the CRM web service. I was able to run the application locally on my development machine, however when I deployed my project to the server, I received the InitializeEx() failed error. The stack trace shows the following:

[ApplicationException: InitializeEx() failed.]
Microsoft.Crm.Passport.LogonManager.Initialize(String environment) +349
Microsoft.Crm.Passport.LogonManager.Logon(String userName, String password, String partner, String policy, String environment) +30

The reason that you received this error message is because the default app pool user does not have permission to initiate the msidcrl40.dll file which called by the IdCrlWrapper.dll

To resolve this issue, I added the following line to my web.config file

<identity impersonate="true" userName="[LOCAL ADMINISTRATOR USERNAME]" password="[ADMIN PASSWORD]" />
If you don't want to touch the web.config file, you may do it through your IIS if you have access to it. Right click on your web site to open up the Properties of your Web site, then click on the ASP.NET tab, then click on the Edit Configuration button.


ScreenHunter_01 Jan. 06 14.43

On the ASP.Net configuration setting screen, click on the Application tab. Check the Local Impersonation checkbox in the Identity settings section. Enter the local Administrator user name and password, then click OK to close the opened windows.

ScreenHunter_02 Jan. 06 14.45

I tried to run my application again and I was able to insert records into CRM from my ASP.net form now. Hope this can help you in your next CRM project.

Sunday, December 21, 2008

SQL 2008

I installed SQL 2008 on my desktop today so I can checkout the new 2008 features. Immediately I can tell you that I like the IntelliSense feature that's built-in to the SQL Management Studio 2008. The table names and field names automatically popup for you. This makes SQL programming much easier.

ScreenHunter_01 Dec. 21 16.45

Also I came across a problem when I try to modify a table already existed in a database, it gave me a error telling me that "Saving changes is not permitted". I do a live search, I found the answer from Robert John MacLean's blog. All I have to do is to go to Tools | Options | Designers in SQL Management Studio 2008, uncheck the "Prevent saving changes that require table re-creation" option and click "OK". Now I can save my changes to the table.

ScreenHunter_02 Dec. 21 16.53

Friday, December 19, 2008

Create Activities using the Dynamic Entity Way

I haven't touch CRM SDK for a while since I am working on another project not directly related to CRM. One of my old client required us to populate CRM with some more training data so they can use it for their training. So I have to modify the training processor that my teammates wrote to add activities to CRM. It appears to me that everything in the training processor have used Dynamic Entity for create, update, and delete.

To create an activities using dynamic entity is pretty straight forward, however I got stuck when I have to deal with the sender and recipient fields on a phone call, email, appointment and fax activity. Sender and Recipient field are ActivityParty type, I have done some research online and I was not able to find a way to associate the two fields to an activity using the dynamic approach. After going through the SDK and I was able to figure it out. I would like to share it since you might have to do the same in your next project.

Method 1: Not using Dynamic Entity

activityparty actParty = new activityparty();
actParty.partyid = new Lookup();
actParty.partyid.Value = new Guid("ENTER CONTACT GUID");
actParty.partyid.type = "contact";

activityparty actParty2 = new activityparty();
actParty2.partyid = new Lookup();
actParty2.partyid.Value = new Guid("ENTER USER GUID");
actParty2.partyid.type = "systemuser";

phonecall call = new phonecall();
call.from = new activityparty[] { actParty };
call.to = new activityparty[] { actParty2 };
call.description = "Test";

crmService.Create(call);



Method 2: Using Dynamic Entity




Property subject = new StringProperty();
((StringProperty)subject).Name = "subject";
((StringProperty)subject).Value = "Test";

Property description = new StringProperty();
((StringProperty)description).Name = "description";
((StringProperty)description).Value = "Test";

// Create From:
Property party1 = new LookupProperty();
((LookupProperty)party1).Name = "partyid";
((LookupProperty)party1).Value = new Lookup();
((LookupProperty)party1).Value.type = "contact";
((LookupProperty)party1).Value.Value = new Guid("ENTER CONTACT GUID");

DynamicEntity actParty1 = new DynamicEntity();
actParty1.Name = "activityparty";
actParty1.Properties = new Property[] { party1 };

DynamicEntityArrayProperty from = new DynamicEntityArrayProperty();
((DynamicEntityArrayProperty)from).Name = "from";
((DynamicEntityArrayProperty)from).Value = new DynamicEntity[] { actParty1 };

// Create To:
Property party2 = new LookupProperty();
((LookupProperty)party2).Name = "partyid";
((LookupProperty)party2).Value = new Lookup();
((LookupProperty)party2).Value.type = "systemuser";
((LookupProperty)party2).Value.Value = new Guid("ENTER USER GUID");

DynamicEntity actParty2 = new DynamicEntity();
actParty2.Name = "activityparty";
actParty2.Properties = new Property[] { party2 };

DynamicEntityArrayProperty to = new DynamicEntityArrayProperty();
((DynamicEntityArrayProperty)to).Name = "to";
((DynamicEntityArrayProperty)to).Value = new DynamicEntity[] { actParty2 };

 

// Create Phone Call Activity:
DynamicEntity activity = new DynamicEntity();
activity.Name = EntityName.phonecall.ToString();
activity.Properties = new Property[]{subject, description, from, to};

TargetCreateDynamic target = new TargetCreateDynamic();
target.Entity = activity;

CreateRequest request = new CreateRequest();
request.Target = target;

CreateResponse response = (CreateResponse)crmService.Execute(request);




That's it! Hope this will help you in your next project! :)

Wednesday, December 17, 2008

CRM 4.0 - Install CRM Language Pack

It's my first time using Camtasia, I just want to make a simple video to test Camtasia and to see if it works on my blog.

Cool, it works!

CRM 4.0 List Web Part Available!

CRM 4.0 List Web Part is available to download today. The list web part supports Multi-tenancy, IFD, 64bit and many more new enhancements comparing to the previous release.

System Requirement:

  • Windows Server 2003 or Windows Server 2008
  • Microsoft Dynamics® CRM 4.0
  • Microsoft Windows® SharePoint® Services 3.0 SP1
  • Microsoft® Office SharePoint® Server (MOSS) 2007 SP1
  • Microsoft® Internet Explorer 6 with SP1 or later versions

To download the list web part, click on the link below.

http://www.microsoft.com/downloads/details.aspx?FamilyID=3b6eb884-ec15-4288-a2a3-d0b47e057458&DisplayLang=en

Close Opportunity via SDK

To close a CRM opportunity is different comparing to other CRM entities. If you want to close an opportunity, you need to use the WinOpportunityRequest and LostOpportunityRequest in the CRM SDK instead of the SetState requests. The code snippet below simply shows you how to set an opportunity to Win status via the CRM SDK.

opportunityclose close = new opportunityclose();
close.opportunityid = new Lookup();
close.opportunityid.Value = targetOppId;

WinOpportunityRequest request = new WinOpportunityRequest();
request.OpportunityClose = close;
// Update the status code according to your environment
request.Status = 1;

crmService.Execute(request);