"Always start with where the error is, then what the error is" I am MVP, founder and CTO at CRM-Konsulterna AB a company specializing in only Microsoft Dynamics CRM.
Wednesday, April 04, 2007
Ease the trouble of developing callouts
Microsoft Swedens CRM expert, Jonas Deibe, has written a posting on his blog concerning how to recycle the application pools instead of resetting the IIS, which means that CRM doesn't have to be compiled just-in-time each time, saving you lots of hair, and time.
So, have a look at his posting: http://blogs.msdn.com/jonasd/archive/2007/03/28/use-build-events-to-recycle-application-pool-instead-of-iisreset.aspx
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Friday, March 30, 2007
What the H*!LL is the bug? - Debugging the right way...
When you get a bug, what is the first question you ask yourself? What the H**LL is the problem?!!!! Well, that phrase actually puts the finger on it. You’re asking the wrong question! It is usually quite difficult to know WHAT the problem is when you don’t know WHERE it is. So the first question should be, WHERE the h****ll is the problem? When you know where exactly the bug is in the code, the question to WHAT the h***ll is the problem? Is usually trivial or very simple.
Might seem a bit too obvious? Think about it, and think about it the next time you're debugging, and I think you might learn to appreciate it.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
New CRM SDK
http://www.microsoft.com/downloads/details.aspx?FamilyId=9C178B68-3A06-4898-BC83-BD14B74308C5&displaylang=en
Talked to my collegue Michael Jansson today and he told me he met some guys down in Malmö who said they followed my blog. Thanks guys, to know that there are some really sharp CRM and SharePoint consultants that find this blog valuable is a great compliment. If there is anything concerning CRM and SharePoint you would like me to blog about, please send me a mess and I will see what I can do. Nothing is to basic, there will always be people who are new to CRM and SharePoint, and if you're not careful, they might be way ahead of you in no time at all.
I have also seen the first screenshots from Titan (code name for the next version of CRM) and it looks really good and there seems to be some really inovative features that will boost this already great program! So, be there or be square (swe: "Var där, eller var rektangulär ;)
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Monday, March 19, 2007
SharePoint & Exchange Forum 2007
If you live close to Sweden or close to Europe for that matter, make sure not to miss SharePoint and Exchange Forum 2007 in Sweden, the 14:th and 15:th of May. It is THE place to be for all SharePoint (and Exchange) professionals, decision makers, developers, administrators and powerusers. I will be the presentor for one of the tracks and I will also be holding a seminar on SharePoint and Microsoft CRM integration.There will be a host of very prominent speakers, some of these will be:
Patrick Tissegheim, SharePoint MVP & author, Belgium
Michael Noel, SharePoint MVP and expert on MS ISA, author, USA
Nick Swan, SharePoint MVP, USA
Göran Husman, SharePoint MVP & Author
Eric Legault, Outlook MVP and author, USA
Scott Schnoll, Exchange expert, Microsoft, USA
Micke Nyström, Windows Server MVP
Lasse Pettersson, Exchange MVP
Peter Andersson, Microsoft Sweden
Kalle Becker, Microsoft Sweden
Pontus Haglund, Microsoft Sweden
Magnus Danielsson, Microsoft Sweden
Christer Olsson, Exchange expert, Microsoft Sweden
Michael Jansson, SharePointexpert and trainer, Humandata
So invest in your social network and knowledge from the worlds most competent SharePoint and Exchange Experts! Not to be there is not an option...
There are a limited amount of seats so make sure you get one! Go to www.seforum.se for more information!
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Thursday, March 15, 2007
Bugg found in SharePoint 3
Well, not a big problem, we thought, we'll just change it back. Well... we couldn't... so we were stuck with a "non-Title-name". Bad, really bad. The only way I found of resetting this, was to delete the entire sitecollection (I had changed the site column at the top site) and the creating a new one. Not a very nice workaround...
So, be ware, don't change the "Title" site column located in the group "_hidden".
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Wednesday, March 14, 2007
Content Query Web Part
http://msdn2.microsoft.com/en-us/library/ms497457.aspx
Here is another blog posting concerning the same theme:
http://www.microsoft.com/belux/msdn/nl/community/columns/stevenvandecraen/contentquerywebpart.mspx
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Monday, March 12, 2007
Different versions of MOSS
http://office.microsoft.com/search/redir.aspx?AssetID=XT102011901033&CTT=5&Origin=HA101978031033
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Thursday, March 08, 2007
New CRM 3.0 Partner Preparedness Tools Available
"CRM 3.0 Partner Preparedness Tools".
Please check it out at the following site:
Jim glass blog
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Wednesday, February 28, 2007
Callouts in Service Provider Edition of Microsoft CRM 3
Finally!
I got it to work, and it actually wasn't too difficult when I got hold of the correct DLL:s. So, first hot tip, right out the furnace:
"When developing for CRM Service Provider Edition, make sure you got CRM Service Provider Edition versions of your dll:s".
This can actually be a bit problematic when working in a development environment on a VPC since it is quite rare to have the entire Hosted Environment, like Hosted AD, Hosted Exchange etc on your virtal machines. If you do, great, use it, but I would guess that most of you don't.
I will give you a short walkthrough of how to create a post callout using the CRM Service Provider Edition. I will focus mainly on the differences between developing a normal callout and one for for CRM SPE.
First off, copy the file Microsoft.Crm.Platform.Callout.Base.dll from the CRM SPE CD 1 (\bin\Assembly). Put it somewhere where it is possible to add a reference to it. Like c:\temp.
Now, add a reference to it in the project.
Modify the callout.config.xml file just like you usually do, for instance:
<callout.config version="3.0" xmlns=" http://schemas.microsoft.com/crm/2006/callout/">
<callout entity="account" event="PostUpdate">
<subscription assembly="CalloutLibrary.dll" class="CalloutLibrary.AcctCallouts" />
</callout>
</callout.config>
Create a class file called AcctCallouts in the namespace CalloutLibrary and make sure the dll is called "CalloutLibrary.dll". (If you name your project CalloutLibrary, this will be default).
using System;using Microsoft.Crm.Callout;
using System;using System.Data;
using System.Net;
using System.Web;
using MSAB.CalloutLibrary.CRMSDK;
using Microsoft.Crm.Callout;
using System.Globalization;
using System.IO;
namespace CalloutLibrary
{
public class mbaktivitet: CrmCalloutBase
{
private CrmService service;
private WhoAmIRequest userRequest;
private WhoAmIResponse user;
public override void PostCreate(
CalloutUserContext userContext,
CalloutEntityContext entityContext,
string postImageEntityXml)
{
string usr = "username@test.local";
string pwd = "1m0rePassword";
string HostedCRMurl ="http://crmserver.hostingcompany.com";
service = new CrmService();
service.Url = HostedCRMurl + "/mscrmservices/2006/crmservice.asmx";
service.CookieContainer = new CookieContainer();
service.CookieContainer.Add(GetCRMCookie(HostedCRMurl, usr, pwd));
//Make sure the webservice works
userRequest = new WhoAmIRequest();
user = (WhoAmIResponse) service.Execute(userRequest);
}
}
}
The important call here is the GetCRMCookie(HostedCRMurl, usr, pwd), a method that I will describe bellow which returns an authentication cookie that can be used to authenticate against the web service. Here is its definition, it is more or less what Arash has written on his blog concerning how to write web services for CRM SPE.
public Cookie GetCRMCookie(string url, string userName, string password)
{
DebugText("Start of GetCRMCookie");
Cookie authCookie;
try
{
Uri serverUri = new Uri(url);
Uri logonServerUri = new Uri(serverUri, @"LogonServer/Logon.aspx");
string encodedUserName = HttpUtility.UrlEncode(userName);
string encodedPassword = HttpUtility.UrlEncode(password);
string logonServerUrl = String.Format(CultureInfo.InvariantCulture, "{0}?UserName={1}&Password={2}", logonServerUri.ToString(), encodedUserName, encodedPassword);
// Make a web request that does not allow redirection
HttpWebRequest logonRequest = (HttpWebRequest)WebRequest.Create(logonServerUrl);
logonRequest.AllowAutoRedirect = false;
logonRequest.CookieContainer = new CookieContainer();
HttpWebResponse logonResponse = (HttpWebResponse)logonRequest.GetResponse();
authCookie = null;
using (logonResponse)
{
if (HttpStatusCode.Found != logonResponse.StatusCode)
{
// throw new CrmException(logonServerUrl, ErrorCodes.InvalidOperation);
}
if (null == (authCookie = logonResponse.Cookies["CRMAuthCookie"]))
{
// throw new CrmException(logonServerUrl, ErrorCodes.InvalidOperation);
}
}
// Now we have the cookie, make sure the credential is valid by passing the cookie back to CRM
logonRequest = (HttpWebRequest)WebRequest.Create(serverUri);
// The following user agent is required by CRM
logonRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)";
logonRequest.AllowAutoRedirect = false;
logonRequest.CookieContainer = new CookieContainer();
logonRequest.CookieContainer.Add(authCookie);
logonResponse = (HttpWebResponse)logonRequest.GetResponse();
using (logonResponse)
{
if (HttpStatusCode.OK != logonResponse.StatusCode)
{
throw new InvalidOperationException(logonServerUrl);
}
}
return (authCookie);
}
catch (Exception err)
{
return null;
}
}
That’s about it. Using this technique, you should be able to get your SPE Callouts to work.
Make sure that the callout.base is exists in the servers GAC, if not, copy it there.
Note that post-callouts, won’t break the execution if there is an error but they will leave the error exception sprecification in the eventlog so make sure you have a look at it.
So, in short, there are two main differences when developing callouts that use web services when comparing normal CRM with SPE CRM, they are:
- DLL:s are unique. The version number for SPE is 3.0.5745.0 while the version for the normal CRM is: 3.0.5300.0.
- To authenticate, you cannot use the normal System.Net.CredentialCache.DefaultCredentials but, you have to use the “slightly” more complicated method of capturing the authentication cookie and using it to log in.
As you might have noticed in the code, the user is hard-coded, which means that there will not be any impersonation in the way it works in normal CRM. I have an idea of how this might be solved; by creating a new aspx-page to capture the username and password, creating a cookie using these credentials and then storing it in the session variable to enable further loggin in later with the webservice. One would also have to make sure that the cookie can be used by the normal IE klient as well. As you might understand, there are some question marks here that I will try to straighten out. If I find a solution to impersonation in CRM SPE, I will be sure to create a post about it!
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Tuesday, February 27, 2007
Service Provider Edition / Hosted CRM
I am developing callouts and will write some more about what the differences are, for now I will leave you with a reference to a blog that actually mentiones something about this.
For one, there is a different version of Microsoft.Crm.Platform.Callout.Base.dll and there is a different way of authenticating when using the webservice. I will write I bit more about it later.
Have a look at this blog for now: Microsoft.Crm.Platform.Callout.Base.dll
http://crm.davidyack.com/journal/2006/7/21/callouts-and-the-service-provider-edition.html
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Import of customizations not working in IE 7
http://blog.sonomapartners.com/2007/01/importing_custo.html
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Wednesday, February 21, 2007
How to create many-to-many relationships in CRM
http://blogs.msdn.com/crm/archive/2007/02/15/many-to-many-relationships-in-ms-dynamics-crm-3-0.aspx
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
CRM Analytics foundation
http://www.codeplex.com/crmanalytics
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Monday, February 19, 2007
MOSS and CRM Webparts
Please click this posts heading to go to the posting I found.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
IFrame security problems
I had some problems with the dymanic functionalities of the report, which didn't work. After some work, I found that it was due to the fact that the Reporting Server had the wrong security settings in IE, and hence was prohibited to fully use the JavaScripts that controlled the drill-down of the reports. The simple solution was to add the reporting server to Local Intranet Sites in IE.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Monday, February 05, 2007
How to create .NET-class files from xsd files
To some of you, this might be yesterday’s news, but for those of you who havn't tried it, you should.
I will try to explain how to do it here. In this example, we'll be basing the .NET class on a InfoPath form. InfoPath is, as you might know, just a front-end to XML, ie. a user friendly way of creating xml-data.
Create you xml-form in any way you like. I won't go into how exactly you do that, but
That will create a schema in the background. To export it to an xsd-file, select “Save as source files…” from the file menu and direct it to a directory of your choice, for instance, “c:\temp”.
Use the file explorer, go to the directory where you just saved the files, and you will find a file with the name of your different data sources followed by the extension “.xsd” in this directory. Remember the name of the xsd-file, let’s call it “source.xsd” in this example.
Then, start up a “Visual Studio 2005 Command Prompt”, go to the directory where you saved the source files, for instance:
cd c:\temp
Then, using the command xsd you can create the cs-file containing the .NET-class with the following command:
xsd source.xsd /c
This will create a new file called “source.cs”. This is the file that contains the .NET class.
Now open your development project and add the file source.cs to the project. This will now give you access to the .NET class in you project. Open the file and you can see the name of your class, it should be “myFields”.
Now we want to instantiate the class with some xml-data. This is done in the following manner using c#-code.
XmlSerializer serializer = new XmlSerializer(typeof(myFields));
XmlTextReader reader = new XmlTextReader(“c:\XmlInstanceOfSourceXsd.xml”);
myFields fields = (myFields)serializer.Deserialize(reader);
Now, you can access the xml-data using the instance fields of the class myFields.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Wednesday, January 31, 2007
News about Titan
In the article from MS (click the heading of this post) they mention that they are planning to release Titan in mid 2007. The last release for version 3, was actually ahead of schedule so, I believe we could actually expect it to arrive in Q3 2007.
Some of the new features that are rumored to be found in Titan are multi-language (in the same installation) and multi-currency. Features that will enable MS CRM to move into the league of the more international companies.
When I hear more, I will surely let you know!
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Tuesday, January 30, 2007
How to create an CRM email with a report server attachment as a pdf
To make it a bit flexible, I created a function that could be called from the workflow engine.
Here is the method declaration that I will use bellow:
public string SendMailWithReport(System.Guid OrderId, string subject, string body, string reportpath, string callerXml)
The parameters are as follows:
OrderId – A Guid containing the orderid to be used as a parameter to the report.
Subject – a string that will contain the mail subject.
Body – a string that will contain the mail body
Reportpath – to make it a bit more flexible, the report path is not hard coded but can be inputed as a parameter,
callerXml – standard handling for getting the caller data to enable impersonation.
The first thing we want to do is to get the pdf from the report server.
We’ll store the binary pdf in the byte-array called result. When this is done, we’ll encode this into a string called encoded data. The rest is stuff that is needed to make this happen.
string encodedData = "";
//Create Report PDF
ReportingService rs = new ReportingService();
rs.Credentials = new System.Net.NetworkCredential(username, passwd, domain);
Byte[] result;
string encoding;
string mimetype;
ParameterValue[] parametersUsed;
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = "CRM_OrderId";
parameters[0].Value = "{" + OrderId.ToString() + "}";
Warning[] warnings;
string[] streamids;
result = rs.Render(reportpath,
"PDF",
null,
null,
parameters,
null,
null,
out encoding,
out mimetype,
out parametersUsed,
out warnings,
out streamids);
encodedData = System.Convert.ToBase64String(result);
The most complex part of this which took me the most time, was the “Render” method of the reporting server web service. I use it this way because it works, don’t ask me what all the parameters really are, I don’t know.
The next part is to create the CRM mail. This is quite straight forward, if you are used to the crm web service.
The “from” and “to” can be set to anything that can be used as a “to” or “from” in the CRM GUI.
CrmService service = new CrmService();
service.CallerIdValue = new CallerId();
service.CallerIdValue.CallerGuid = GetCaller(callerXml);
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Get current user
WhoAmIRequest userRequest = new WhoAmIRequest();
WhoAmIResponse user
= (WhoAmIResponse) service.Execute(userRequest);
//Load salesorder and account objects.
salesorder so = (salesorder)service.Retrieve(EntityName.salesorder.ToString(), OrderId, new AllColumns());
account acc = (account)service.Retrieve(EntityName.account.ToString(), so.customerid.Value, new AllColumns());
email em = new email();
activityparty from = new activityparty();
from.partyid = new Lookup();
from.partyid.type = EntityName.systemuser.ToString();
from.partyid.Value = user.UserId;
em.from = new activityparty[] {from};
activityparty toparty = new activityparty();
toparty.partyid = new Lookup();
toparty.partyid.type = EntityName.account.ToString();
toparty.partyid.Value = acc.accountid.Value;
em.to = new activityparty[] {toparty};
em.subject = subject;
em.sender = "test@test.com";
em.regardingobjectid = new Lookup();
em.regardingobjectid.type = EntityName.salesorder.ToString();
em.regardingobjectid.Value = so.salesorderid.Value;
em.description = body;
em.ownerid = new Owner();
em.ownerid.type = EntityName.systemuser.ToString();
em.ownerid.Value = user.UserId;
Guid createdEmailGuid = service.Create(em);
Now, we have created the email. You can see it in CRM if you like.
The last part is now to create the attachment on the email as the pdf that we downloaded from the report server in the first part of this walk-through.
activitymimeattachment ama = new activitymimeattachment();
ama.activityid = new Lookup();
ama.activityid.type = EntityName.email.ToString();
ama.activityid.Value = createdEmailGuid;
ama.body = " ";
ama.mimetype = "application/pdf";
ama.attachmentnumber = new CrmNumber();
ama.attachmentnumber.Value = 1;
ama.filename = "A filename";
Guid createdAttachment = service.Create(ama);
//Upload file
// Create the Request Object
UploadFromBase64DataActivityMimeAttachmentRequest upload = new UploadFromBase64DataActivityMimeAttachmentRequest();
// Set the Request Object's Properties
upload.ActivityMimeAttachmentId = createdAttachment;
upload.FileName = "attachmentfilename.pdf";
upload.MimeType = "application/pdf";
upload.Base64Data = encodedData;
// Execute the Request
UploadFromBase64DataActivityMimeAttachmentResponse uploaded = (UploadFromBase64DataActivityMimeAttachmentResponse) service.Execute(upload);
The last part, if you want to, is to send the mail:
SendEmailRequest req = new SendEmailRequest();
req.EmailId = createdEmailGuid;
req.TrackingToken = "";
req.IssueSend = true;
SendEmailResponse res = (SendEmailResponse)service.Execute(req);
I have made some simplifications, like removing try-catch clauses, which you really should use, but the code has apart from that been cut-n-pasted from a working application and should work.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Thursday, January 25, 2007
A question from a CRM admin
---
Hi Gustaf,
Let me introduce myself, I am XXX new to MS CRM. I got your mail id through your blog.I am mailing you as we have a urgent query with respect to mscrm. We have a company domain, which is being used by the entire organisation, now if i am going to install MS CRM 3.0 Server setup do we need to have a different domain/domain controllers for the CRM. Are their any issues which must be taken care of before going ahead, as we will be dealing with the live domain. The objective of this is to integrate with sharepoint technologies. I will be thankful for your earlier response.
Regards, XXX
---- My answer:
Hi,
When you install MS CRM 3 it will add a few groups to the AD, but apart from that will not touch the AD. MS CRM:s user handling and security information is stored in the MS CRM database hence no need for further schema extensions of the AD.
I understand your concern when installing on a live domain but there should not be any problems. If you still feel a bit worried, you can always install MS CRM in a virtual environment and see the changes for you self.
The live CRM server should be installed in the company domain.
Kind regards,
Gustaf
------
If your question is in regard to something I've posted on the blog, please add it as a comment, otherwise, you can always mail me. Please note that I will gladly answer technical questions like the one above but it is not feasable for me to design you solution. If you want my help in that aspect, please contact Humandata (www.humandata.se) and we can get you a good deal. I hope you appreciate that even I need to have a house to live in and food for my family :)
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se
Back again - with a question
I've tried to find out a bit more about the upcoming integration engine CRM-Nav from Microsoft but have not been very successful. The main question is what kind of infrastructure it will be based on and I think the following three are the hottest tips:
1. Celenia/Tectura - The integration formerly known as Tectura, (see my previous postings), now called the Celenia CRM-Nav integration, has previously been put forward by Microsoft as THE integration engine to use.
2. BizTalk based integration - BizTalk is the talk of the town concerning integration, and it would not be very strange if the integration would be BizTalk based.
3. New/Custom - They might just have sat down and started from scratch and written an integraiton engine specifically for CRM-Nav.
Well, where's my money? To start off, Microsoft have been very very quite about this integration engine, would seem a bit strange if the engine would be according to 2 or 3 above, when there really would be no reason for that.
However, if they are up to an aquisition of Celenia or just the program, then they would probably like to be just very very quite about it until all the formalities had been settled.
Another reason for not going along with 2, the BizTalk version, is that it would require an installation of BizTalk at each customer which might cause more problems and costs than what is reasonable.
One reason for not choosing 3 is that it most probably will be quite costly.
Something to take into consideration in the Celenia business is that the integration engine was previously owned by Tectura (although it had been developed by Celenia) but for reasons unknown to me, was reverted to Celenia. Most probably after considerable preasure from Microsoft.
Bottom line, my money is on the Celenia integration (1). Which versions of Nav it will support is still unknown and if it will still only be a technical integration is also still unknown, when I learn more, I will let you know.
Gustaf Westerlund
CRM and SharePoint Consultant
Humandata AB
www.humandata.se