More About This Website

All information is provided "AS IS" with no warranties, and confers no rights

Login
Powered by Squarespace
Monday
Sep202010

Exploring CRM 2011 Solution Framework Update Scenarios

In this blog post I’m going to explore some the different scenarios you might encounter with the solution framework in CRM 2011. This blog post is based on the beta of CRM 2011 version was released in September 2010. This is not an introduction to solutions, but rather an advance look at some of the different scenarios that might be encountered when using the solution framework. If you are new to solutions, you might just want to bookmark this blog post until you've looked at some of the basics first. I will also be doing some more basic introduction blog post in the future as well but since I was in the middle of testing these scenarios I thought I'd share them right away.

Test Baseline

The following establishes the solution to be used for the testing. Think of it as the 1.0.0.0 of the test product.

Created a new publisher

clip_image001

Created a new solution

clip_image002

Next I created two test entities A and B each having two string attributes.

clip_image003

And the journey begins by exporting the solution as a managed solution version 1.0.0.0 and importing data into a new organization has managed.

Simple Update, Add new Attribute to Entity A, change version number to 1.0.0.1.

clip_image004

All looks good – now we get the choice for maintain or overwrite, we will take maintain.

clip_image004[1]

Import an older version, in this case 1.0.0.0 when 1.0.0.1 is installed

clip_image005

It knows that the version number is different but it doesn't warn you that you're about to install an older version. Essentially the best way to think about version number is metadata.

Checking the attributes all 3 are still listed even though 1.0.0.0 only had two.

clip_image006

Trying to import a managed version on top of the unmanaged entities.

clip_image007

Nope, I knew it wouldn’t work, but wanted to make sure you knew.

Creating 1.0.0.2 and removing Test Entity A – Attribute 2

clip_image008

In the target Org, I added the entity to workspace, added the three fields to the form, and added a test record while we were doing the other tests.

clip_image009

Import worked fine just like before – and the 3 attributes were still in the target organization meaning it didn’t magically remove them

clip_image010

Install into a new clean organization of 1.0.0.2 only ends up with the 2 attributes

clip_image011

This means new customers installing a solution will not see the deleted attribute.

Create 1.0.0.3 – Remove Entity B and import to organization with 1.0.0.2 already installed

All worked ok, as you can see only Entity A was processed there is no mention of entity B

Looking into the installed solution we see that it still has Entity A and B

clip_image013

So it seems the behavior is the same as attributes

Uninstalling a Solution – What happens to the Data and Your Customizations?

This is one to be careful with because it might not work the way you would want it to. First you see the following prompt.

clip_image014

In my case remember I had modified the default solution to add the fields to the form, and had created a single record of type Entity A. After this completed the site map change was gone, the entity and it’s data was gone. In some ways you can think of this no different than if you customized some other file for an installed application. Ideally, I would like the person removing to see a detailed list of data the will lose so they aren’t surprised or some other safeguards. For now though the important thing is to understand the current behavior so you aren’t surprised.

Wrap up

Hopefully that gives you helps explain some of the behaviors of the solution framework that is a part of CRM 2011. As you probably figured out by now solution can be either really simple or really complex depending on a particular application. They enable scenarios that we used to think weren’t possible before and it also creates scenarios that we might not fully understand yet. I'll try to do some more of these exploring the solution framework posts in the future. If you have ideas of things you'd like to see leave them in comments.

Thursday
Sep162010

Generating a Device ID for use with CRMSvcUtil

When you are working with CRM 2011 Online Beta and want to generate typed classes
using CRMSvcUtil you need to first generate a device ID and device password.

There are some specific rules you must follow when generating these. To help make
that easier the SDK includes a helper class named DeviceManager.cs. In order to use
this helper class you still have to create your own program that calls its helper
methods. To make that easier I have created a simple program that calls those
methods for you and placed it on MSDN code Gallery. You can download the source
code and executable from the following link http://tinyurl.com/24jooe7

Once you download and run this utility it will generate a device ID and device
password for the machine that you run it from. The output from this is specific to
the machine you run it from and is not intended to be shared on multiple machines
(devices). The output should look something like the following:

clip_image001

When running CRMSvcUtil you will pass this either on the command line or in the
config file. From my experience the config file approach is more reliable. I’ve
encountered times when passing on command line didn’t work but config file did. 

The following is an example of what the config file would look like:

<configuration>

<appSettings>

<add key="deviceid" value="11f61111111notreal" />

<add key="devicepassword" value="uiD111111I%v0notreal" />

</appSettings>

</configuration>

The file would be named crmsvcutil.exe.config and must be in the same folder as
the crmsvcutil.exe.

You would then run crmsvcutil with a command line that looks like

crmsvcutil.exe /url:https://<CRM Online URL>/XRMServices/2011/Organization.svc /out:GeneratedEntities.cs
/username:<LiveID> /password:<LiveIDPassword>

If you want to try the commandline approach instead of using the config file you
would add the following to your command above:

/deviceid:”<deviceid>” /devicepassword:”<devicepassword>”

This should create a file called GeneratdEntities.CS after it runs successfully.

If for some reason you have trouble you might want to try clearing your cached
device ID and device password. The device manager utility stores the device ID and
password in %USERPROFILE%\LiveDeviceID\LiveDevice.xml

Hopefully by the time we get past beta they can figure out a way we don't have to
mess with the device stuff and it's just handled for us by the utility.

Monday
Sep132010

Next Generation Application Framework Hits Beta

Last week Microsoft released a beta version of Dynamics CRM 2011. CRM 2011 has been in private preview mode over the last couple of years and is now available for public beta. Over the course of that time I’ve had the chance to kick the tires and provide feedback and see it evolve. I’ve also had a chance to run training events in several countries and see the excitement of the ISVs involved early on. I’m excited to see this milestone hit so it can now get out to a larger number of developers.

Latest Framework, Latest Tools
.NET 4, Visual Studio 2010, SQL 2008 R2, SharePoint 2010 all wrapped up in a pre-integrated application framework is the simple way to describe CRM 2011. Sure it’s good at the CRM (Customer Relationship Management) stuff but the real story from my perspective in CRM 2011 is the continued expansion of the capabilities of using CRM 2011 as the application framework for a much broader set of line of business applications. Is it right for every application? No. But should it be considered? Yes. I love building application plumbing (application infrastructure) as much as the next guy, but in current economic times it no longer always makes sense every time.

CRM and SharePoint – Like Chocolate and Peanut Butter
CRM 2011 introduces out of the box integration with SharePoint for document management. It’s my hope that is the first of more integration between the two products. Separately, neither is the dream application framework story yet, but together they would be unstoppable. I believe the end goal should be .NET, SQL etc. all the raw components at the lowest level. I always call this “some assembly required” because it’s up to you to integrate all the parts. This low level would be used by developers building things like Stock Trading applications with high volume, or real time mission critical systems like running a space shuttle. SharePoint and CRM would be combined together out of the box as a single product. Taking the collaboration and document management from SharePoint and related data and declarative development from CRM

Solution Packaging Expanded
Prior to CRM 2011 exporting and importing used to be limited to customizations. CRM 2011 introduces the concept of solutions. Solutions can contain the customizations plus things like the code for a plug-in, workflow and Silverlight. Solutions can be exported for distribution and then imported (installed) in the target system. They will be a key part of Microsoft’s CRM App Store. Solutions can be locked down to limit what others can customize if needed. More importantly, solutions can be layered and updated in place. This allows applications to be built from building blocks of solutions. Some provided internally, some provided by 3rd party ISVs. Together these solutions represent a complete application.

Silverlight or HTML/JQuery – You Choose

In CRM you create a custom entity (like a database table) you automatically get security, workflow, reporting and a user interface without doing any development work. In prior versions of CRM you could do IFrames that included custom application content. You used to have to figure out how to manage that content on your own outside of CRM. CRM 2011 introduces Web Resources that allow uploading of HTML, JavaScript, Silverlight and more and let it be hosted by CRM. This enables for example a Silverlight application xap file to be uploaded to CRM, and the developer or customizer later can simply insert it onto the form without any development. You can do the same thing with HTML/JQuery if you prefer that style as well. Personally, I believe that Silverlight is a better fit for extending CRM 2011 and that JQuery/HTML is better for building more externally facing broad consumption sites. But again CRM 2011 supports both so you can choose. For those of you that do go down the Silverlight Path, we are working on a CRM 2011 Silverlight book. It will take the core parts of our Silverlight 4 Jumpstart book and add on a bunch of CRM 2011 specific Silverlight content. More details on this will be posted soon but if you want to get started you can buy the Silverlight 4 book and we will have a special offer for you to move up to the CRM 2011 book once it’s released. You can find the Silverlight 4 Jumpstart book here.

Your Cloud, My Cloud, The Cloud
It just doesn’t matter, just pick what works. CRM grew up being an on premise with people installing everything locally. Back in (I think it was) 2008, CRM Online was launched along with the idea of partner hosted. We’ve run CRM internally for years, but with CRM 2011 and the fact that almost everything including deploying code to the server works the same we are planning on moving to online. Where ever possible we have been trying to get out of the server maintenance business and letting someone else do it. CRM 2011 also introduces the ability to connect things together using the AppFabric Service bus. Using the service bus capabilities you can publish events to the other listening applications when events occur in CRM.

Getting Started and how to avoid the Robot

Clearly this is just the beginning, there is so much more to talk about than a single post can cover. To download the beta or sign up for access to CRMOnline beta head to http://www.crm2011beta.com. From there you can also hit the developer tab and download the SDK which includes a lot of good information including some samples and walkthroughs. Whatever you do avoid the videos on that site. I would swear the voice over talent used is a robot and will drive you insane after the first 5 minutes of listening. Look for community content to start showing up everywhere now that the NDA is lifted and save the time listening to the robot other things. This one is a bit long (almost 2 hours) but it gives a great tour of CRM 2011, and is a good place to start.

I could ramble on for a while about CRM 2011; in fact this is just the beginning of what I have planned. First of all we have already talked about the Silverlight book that is upcoming; we also will be doing some broader content similar to the CRM 4 book (www.thecrmbook.com). Feel free to post a comment with what you would like covered and how. Book, Video, both we are still trying to decide how best to cover all the new CRM 2011 content.

Wednesday
Jun022010

Old SDK – New SDK Query by OwnerId

The latest update to the MSCRM SDK included a new LINQ provider. In this blog post we are going to compare and contrast querying for data by owner ID using the old and new SDK techniques. If you are new to the LINQ provider then you should read my quick start blog post here first.

For this example let’s assume I want to retrieve accounts where the owner ID is the current user. The following is straight from the CRM SDK and uses the lower level API calls. Keep reading past it and I will use the new LINQ provider to accomplish the same thing plus a little bit.

Guid principalId = user.UserId;

// Create a column set holding the names of the columns to be retrieved.

ColumnSet colsPrincipal = new ColumnSet();

// Set the properties of the column set.

colsPrincipal.Attributes = new string[] { "name", "accountid" };

// Create a ConditionExpression.

ConditionExpression conditionPrincipal = new ConditionExpression();

// Set the ConditionExpressions properties so that the condition is true when the

// ownerid of the account equals the principalId.

conditionPrincipal.AttributeName = "ownerid";

conditionPrincipal.Operator = ConditionOperator.Equal;

conditionPrincipal.Values = new object[1];

conditionPrincipal.Values[0] = principalId;

// Create the FilterExpression.

FilterExpression filterPrincipal = new FilterExpression();

// Set the properties of the FilterExpression.

filterPrincipal.FilterOperator = LogicalOperator.And;

filterPrincipal.Conditions = new ConditionExpression[] { conditionPrincipal };

// Create the QueryExpression.

QueryExpression queryPrincipal = new QueryExpression();

// Set the properties of the QueryExpression.

queryPrincipal.EntityName = EntityName.account.ToString();

queryPrincipal.ColumnSet = colsPrincipal;

queryPrincipal.Criteria = filterPrincipal;

// Create the request object.

RetrieveMultipleRequest retrievePrincipal = new RetrieveMultipleRequest();

// Set the properties of the request object.

retrievePrincipal.Query = queryPrincipal;

Now that we have looked at how we would have done this in the past, let’s look at what is possible using the new LINQ provider. First, you should have already read my other blog post where I talked about how to call Who Am I to get the current user ID here. For this example we startup assuming that has already been accomplished.

To make this a little more interesting, in addition to just retrieving the accounts for the user I also want to retrieve the user’s name and only the first 10 accounts.

The first thing we are going to do is build the LINQ expression that will provide the criteria for our query. The following queries for accounts that have an owner ID matching. It also shapes the results into an anonymous type that only has the properties ID and Name. Pause for a second and compare the following 7 lines, which could really be expressed as 1 line to the code we used above without the LINQ provider.

var principalQuery = from acct in ctx.accounts

where acct.ownerid.Value == currentUserID

select new

{

ID = acct.accountid,

Name = acct.name

};

Remember, the above just defines the LINQ expression it doesn’t cause execution of the query against the CRM server that will happen later when we start to enumerate the results. Next, let’s go get the user information so we can grab the full name of the user.

var userInfo =

ctx.systemusers.Where(u => u.systemuserid == currentUserID).FirstOrDefault();

If we retrieved a user the output the user name.

if (userInfo != null)

Console.WriteLine("First 10 Accounts for user " + userInfo.fullname);

Next, we are going to enumerate the accounts and print the account name. Notice that we added a Take(10) onto the LINQ query we built earlier. This will cause only the first 10 records to be used.

foreach (var acct in principalQuery.Take(10))

Console.WriteLine(" Account Name :" + acct.Name);

Hopefully it’s clear from the example the new CRM LINQ provider that’s part of the updated SDK makes it much easier to build queries against the CRM data.

Thursday
May132010

Using the CRM Service via the DataContext

Last week Microsoft announced the latest update to the MSCRM SDK that included a new LINQ provider. If you are new to the provider then you should read my quick start blog post here first.

In this blog post we are going to look at how you can use the CRM Service when you have a DataContext instance. As you probably recall the DataContext is generated when you run crmsvcutil against your CRM organization. DataContext is a wrapper on top of the standard CRM Service. Sometimes you need to drop down to make calls against the lower level CRM Service. For example, calling Who Am I, working with metadata and any other interaction that requires calling Execute. As it turns out if you have an instance of DataContext it provides an easy way to interact with the standard CRM Service for these types of operations. In the rest of the blog post we are going to look at calling WhoAmI using the DataContext helper methods.

The first approach we are going to look at is using the CreateService method on the DataContext. This method gives back an object instance that implements IOrganizationService. The IOrganizationService interface is a new abstraction as part of the updated SDK that provides methods to interact with both the transactional data in CRM and the metadata. Using the object instance returned from CreateService you can do calls to Execute just like you would from the CRM Service or Metadata Service directly.

Let’s get started making a Who Am I call to the CRM Service using the IOrganizationService instance. The first thing we need to do is add a using for the SdkTypeProxy namespace where the WhoAmIRequest/Response classes reside. Notice we are using an alias of SdkTypeProxy on the using. The reason for that is that name space also contains the “account” entity class and it conflicts with the generated account class created by CrmSvcUtil code generation. By using an alias we can work around this pretty easily.

using SdkTypeProxy = Microsoft.Crm.SdkTypeProxy;

Next, create an instance of the DataContext, remember this class is generated when you ran CrmSvcUtil and might have a different name if you chose something different on the options.

DataContext ctx = new DataContext("mycrm");
Next, define a Guid variable to hold the current user ID we get back.

Guid currentUserID = Guid.Empty;
Next, call the CreateService method on the context to get an instance of IOrganizationService. You will notice a couple of things in the following example. First, we are using “var service” without defining the type. The var keyword causes the type to be inferred from the right side of the statement. In this case it will be inferred to be IOrganizationService since that is what CreateService returns. We are using this approach to keep the code simply and concise without any redundant specification. You will also notice we wrap the code block with a “using”. When coded like below the using ensures that the dispose is properly called on the IOrganizationService instance when it falls out of scope either due to normal completion or an exception. We then proceed to build up a WhoAmIRequest object and call the execute method to get the current user ID.

using (var service = ctx.CreateService())

{

var userRequest = new SdkTypeProxy.WhoAmIRequest();

var user = service.Execute(userRequest) as SdkTypeProxy.WhoAmIResponse;

Console.Write("You are running as user " + user.UserId);

currentUserID = user.UserId;

}

The new SDK also offers another approach that you can use to accomplish the same thing. Instead of calling CreateService you can call the UsingService method which accomplishes the same thing as the “using” statement and the CreateService method call. The following is the revised code adjusted to call the UseService method.

ctx.UsingService(service =>

{

var userRequest = new SdkTypeProxy.WhoAmIRequest();

var user = service.Execute(userRequest) as SdkTypeProxy.WhoAmIResponse;

Console.Write("You are running as user " + user.UserId);

currentUserID = user.UserId;

});

Using either approach you can make calls to the standard CRM Service without having to re-create a connection to the CRM server using the lower level API. Stay tuned as we continue to explore how to use the new LINQ provider that is part of the new SDK.

Thursday
May062010

New CRM SDK, New Developer Experience

Today, Microsoft released CRM SDK 4.0.12  - before you just download it and think its just another minor update – read on. This update includes what is being referred to as Advanced Developer Extensions.  Before you stop reading saying “I’m not advanced” – “Advanced” I believe is marketing’s way of saying this builds on top of the strong foundation that CRM already provided – not that you need to be a “Super Advanced” developer to use it.  In reality, it’s advanced because it’s going to simplify how you interact with the CRM data.  More specifically, it will allow you to use the LINQ expression syntax that developers have been using since C#3/VB9 to build queries.  Additionally, this introduces the idea of using the normal .NET data types instead of the CRM specific ones e.g CRMBoolean.  In the past, CRM had specific types for CRM Boolean because at the time .NET didn’t support nullable types.

There are other good things in the new SDK that I will try to cover in future blog posts – but wanted to make sure people didn’t gloss over this new feature. 

Dave’s 10 Minute Quick Start Walkthrough - (SDK download times excluded of course, I can’t help if you have a slow connection!)

1 – Download the updated CRM SDK

2 – Create a new console application in Visual Studio 2008 or 2010 – choose .NET 3.5 as your framework

3 – Create a folder in the new project called Entities – Right click Open Folder in Browser as you can see below

image

4 – Copy the path name from Windows Explorer – you will need it to provide to the CrmSVCUtil program so it can use it to create the generated classes

image

5 – From a command line – go to the SDK folder/Microsoft.xrm/Tools and run the following command line – replacing MyCrmServer with your actual server name, replace MyCrmOrg with your actual CRM Org and MyEntitiesFolder with the name you copied in step 4.  Note : This assumes using integrated authentication for on-premise – support is available for many different scenarios – check the docs.

crmsvcutil /server:http://MyCrmServer/MyCrmOrg /out:MyEntitiesFolder

This utility will access the server metadata and build classes for each of the entities and place them in your project folder.

6 – Right click – Add Existing Item on the entities folder, Make sure the browse dialog is in the Entities folder and select all the files and click OK

image

7 – Add references to the CRM SDK assemblies – using Add Reference – Browse and choosing the following

image

8 – Add references to the Xrm assemblies from the SDK/Microsoft.xrm/bin folder as you see in the following

image

9 – Add references to the following .NET assemblies

System.Data.Services

System.Data.Services.Client

10 – Build your application you should get a clean build at this point – before we add more code

11- Open the app.config file and add the following connection string section.  Modify the server name to match your server name, and the org name to match your org name  - if you don’t have an app.config – just add one via add-new items

<connectionStrings>
   <add name="mycrm" connectionString="Authentication Type=Integrated;
   Server=http://MyServerName/MyOrgName;"/>
</connectionStrings>

12 –  In the Program.cs file - Add a Using statement for your entities as you can see below

using Entities;

13 – The new API uses a concept of a Data Context – you can think of this as the gateway to working with the CRM data – In the Main method add the following – which creates an instance and references the connection string we added to the app.config

DataContext ctx = new DataContext("mycrm");

14 – Use LINQ to compose a query of accounts.  The following defines the query but does not execute it – with LINQ expressions they get executed when used as we will see later.  The following builds a query looking for all accounts that have an “a” in the name.

var query = from acct in ctx.accounts
                        where acct.name.Contains("a")
                        select acct;

15 – Loop though each of the accounts and print the name – This will cause the actual execution of the query against CRM – Also notice that we can use strongly typed properties no guessing the names of magic strings

foreach (var acct in query)
                Console.WriteLine("Account Name :" + acct.name);

17 – Run the application you should get a list of accounts

18 – See how easy it is to add ordering to a query – add the following to the LINQ query between the Where and the Select

orderby acct.name

image

19 – Run the application again to see names sorted

20 – Let’s add a record – Adding a record is also very easy – First create an instance of the account object and set the minimum – This uses the account class that was generated by CrmSvcUtil earlier

var newAccount = new account();
newAccount.name = "test account";

21 – Add the record to the Data Context – This step advises the context about the new record – but it doesn’t cause the create to happen on the server yet. This means we can do multiple adds / updates and then send them to the server when ready.

ctx.AddToaccounts(newAccount);

22 – Call the SaveChanges method on the context to cause the records to be created on the CRM server

ctx.SaveChanges();

Note : This will really add a record to your server – you have been warned!

Updating is just as easy – modify a record you retrieved from a query and then call UpdateObject(account) to notify the Data Context of the changes.  And of course DeleteObject(account) will make that account vanish for ever –a great way to get rid of pesky accounts :)  Like Add, Update and Delete do not get sent to the server until SaveChanges is called.

Wednesday
Nov182009

Mixing Silverlight 4 with Dynamics CRM

Today we are happy to be able to announce the availability of some Silverlight 4 book content. For existing Silverlight developers looking to get up to speed quickly with the features we are releasing the Silverlight 4 Overview. This is a little over 50 pages of content covering the new Silverlight 4 features.  For the rest of this week using code SL4DaveBlog at checkout you can get the new Silverlight 4 content for only $5 almost half off the normal price.

For developers that are new to Silverlight but are comfortable with .NET we are releasing a preview of Silverlight 4 Jumpstart. Silverlight 4 Jumpstart content builds on the success of the Silverlight 3 Jumpstart book to offer content focused at the business .NET developer.

Both of these offerings are available today and will continue to evolve with the Silverlight 4 release. These are delivered in an electronic format (PDF) and will continue to be updated with more current releases of Silverlight 4.

Stay tuned for a video demo of the following demo including being able to drag files and drop them on the CRM web client using the Silverlight 4 Drop Target support.

The following is an excerpt from the Silverlight 4 Overview chapter that is available as part of Silverlight 4 Jumpstart Preview book or as a standalone chapter from SilverlightJumpstart.com. The full overview chapter covers all the major new features of Silverlight 4 to help you get up to speed quickly.

Microsoft has fast tracked Silverlight to be a strong competitor in the global RIA space and squarely positioned itself against competitors like Adobe, Google and Yahoo for production of the finest RIA toolset. The initial battleground was video, but we are now seeing Silverlight has strong potential for building business applications as well. We have tried through the previous chapters to streamline your learning of the current version of Silverlight by focusing on the key areas a business developer needs to know. Now it’s time to talk about the future and what the road ahead looks like for Silverlight.

It had only been about nine months since Silverlight 2 was released in October 2008 that Silverlight 3 hit the street in July 2009. Then, just four months after the release of Silverlight 3 Microsoft released Silverlight 4 Beta at its Professional Developer Conference in November 2009. Each of these releases build on the prior one to add new features while at the same time keeping compatibility to support this fast pace of innovation.

If I had to pick a single theme for the main items that are part of Silverlight 4 I would have to choose “You Asked, Microsoft built it”. I say that because many of the items like Printing or Web Camera/Microphone support for example were some of the highest user prioritized features. You can check that out for yourself at Silverlight.UserVoice.com and while you’re there add or vote on a couple of your requests.

Silverlight 4 is also a major deal because it’s the first release of Silverlight to support .NET 4 CLR (Common Language Runtime). This gives developers access to the latest runtime features that are added to CLR4 including things like dynamic object support.

In addition to the core Silverlight 4 Beta, Microsoft also released corresponding updates to the other tools and products used with Silverlight. The tools for working with Silverlight from within Visual Studio were updated to support the Silverlight 4 Beta. This includes increased designer support to make it easier to develop Silverlight applications without having to leave Visual Studio for a separate tool. A new version of the Silverlight Toolkit was also released that goes along with the Silverlight 4 update. An update was also released for .NET RIA Services which has now been renamed as WCF RIA Services to reflect the fact that it now rides on top of WCF. This is an evolution of the prior .NET RIA Services releases and positions it to leverage WCF as a foundation to build on going forward. In addition to the WCF change a number of additional features such as improved inheritance support were added to WCF RIA Services in this release. Finally, a preview release of Blend for .NET 4 was released to allow it to work with Silverlight 4.
In the rest of this chapter we are going to preview some of these features that you will see in the Silverlight 4 Beta release.

Web Camera / Microphone Support

Silverlight 4 now allows developers to access to the raw audio and video streams on the local machine from applications running both in and out of the browser. Using these capabilities developers can write applications including capture and collaboration using audio and video. This is built-in to the core runtime and no other special downloads are required on each machine. When the audio or video is accessed for the first time by the application the user will be prompted to approve the request. This ensures that audio and video is never accessed without the user’s knowledge preventing applications that capture silently in the background. The following is an example of the prompt the user sees when the application requests access to the devices.

VideoAudoPrompt

You will notice in the above image the site name is displayed. This is another safeguard to ensure the user knows which site is requesting access to the devices. Access is granted to just this application and only for this session of the application. Currently there is no option to persist the user’s approval to avoid re-prompting each time the application is run. Additionally, it’s all or nothing; you don’t get to choose video or microphone. It’s a combined approval.

Users with multiple devices can select the devices they want to be the default devices using the properties on the Silverlight plug-in. This can be selected by right-clicking on a Silverlight application and going to the Webcam/Mic tab.

The following is an example of what you will see on that tab.choosedefaultmic

Developers can get access to the chosen devices using the CaptureDeviceConfiguration class. Using this class you can call the GetDefaultAudioCaptureDevice or GetDefaultVideoCaptureDevice methods to retrieve the users selected defaults. The class also has GetAvailableAudioCaptureDevices and GetAvailableVideoCaptureDevices methods that allow you to enumerate the available devices if you want more control of choosing a device besides the default.

Prior to using the devices you must request access to the device by calling the RequestDeviceAccess() method from the CaptureDeviceConfiguration class. When this method is called it is responsible for showing the user approval dialog we saw earlier. This method must be called from a user initiated event handler like the event handler for a button click event. If you call it at other times it will either not do anything or produce an error. Using the AllowedDeviceAccess property you can query if access has already been granted to the device.

The quickest way to get started using the video is to attach the capture from the device to a VideoBrush and then use the brush to paint the background of a border. The following XAML sets up the button to trigger the capture and a border that we will paint with a video brush.

<StackPanel>

<Button x:Name="btnStartvideo" Click="btnStartvideo_Click"

Content="Start Video"></Button>

<Border x:Name="borderVideo" Height="200" Width="200"></Border>

</StackPanel>

Next, the following private method TurnOnVideo method is called from the handler for the click event on the button. This satisfies the requirement to be user initiated.

private void TurnOnVideo()

{

VideoCaptureDevice videoCap =

CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

AudioCaptureDevice audioCap =

CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();

CaptureSource capsource = new CaptureSource();

capsource.AudioCaptureDevice = audioCap;

capsource.VideoCaptureDevice = videoCap;

if (CaptureDeviceConfiguration.AllowedDeviceAccess

|| CaptureDeviceConfiguration.RequestDeviceAccess())

{

capsource.Start();

VideoBrush vidBrush = new VideoBrush();

vidBrush.SetSource(capsource);

borderVideo.Background = vidBrush;

}

}

As you can see in the code above, default audio and video devices are retrieved and assigned to a CaptureSource. Access to the devices is then checked and requested if not already approved.

If access is granted the Start() method on the CaptureSource is invoked to begin capturing audio and video. Finally, the VideoBrush source is set to the CaptureSource instance and the background on the border is set to the VideoBrush.

Overtime we will probably see some very interesting applications of the audio and video support. One example that we put together was using it with Microsoft Dynamics CRM. In this example application a membership application was simulated that associated members with pictures and stored the pictures in a database. Think of a place similar to Costco, Sam’s Club or your local gym that snaps your photo for their records.

In the following image you can see how a tab has been added to the Contact form using the CRM customization capabilities.

 

CRMCap1

A Silverlight 4 application is then hosted inside that tab that will provide the user experience for capturing the images. When the Start Camera button is clicked the user will be prompted to approve the access and the video feed will begin as you can see below.

crmcap3

The video feed will keep showing the live image updated from the web cam until stopped. The Capture button on the above application allows the user to capture one of the image frames from the capture source. The AsyncCaptureImage(..) method on the CaptureSource class allows you to request that a frame be captured and your callback invoked. The callback is then invoked and passed a WriteableBitmap representing the captured frame.

crmcap4

This image can then be saved back to the Dynamics CRM server and associated with the record being viewed.

In the above example we looked at how you could use the video capabilities to capture a static image. More advanced applications are also possible for things like collaboration by showing the real time audio and video feed of multiple users.

You have been reading about one of the many new and exciting features of Silverlight 4 that are covered in the complete overview chapter. Visit SilverlightJumpstart.com today to access the full chapter.

Sunday
Oct112009

Are you Rolling Up?

One of the things that always drove me crazy with CRM 3 was when I had a problem and tracked it down only to find out there was a hotfix available.  Further, to get that hot fix I had to call up support and request the update.  Along the way, you would end up with 5-10 hot fixes that were required anytime you installed a client or server.  That became a headache real quick. Sure, there was a rollup for CRM 3 but there wasn’t a plan to keep the pace matching the users needs.  Microsoft heard that and with CRM 4 they have been doing Update Rollup’s on a regular scheduled basis.

Update Rollup’s are released every couple months and contain a set of by the Microsoft CRM Sustained Engineering team.  This was announced back in January here and has continued on with Update Rollup 6 being the current released rollup.  This doesn’t mean that you won’t ever need a hotfix, but it should reduce the need to manage as many special hotfixes. 

One thing I like a lot is you can choose how to introduce the rollup’s into your environment as it makes sense.  Some companies will apply the rollup as soon as it is released from Microsoft, while others might wait a quarter or only apply it if they have problems.  Each of the rollup’s are also broken out into client and server and other components.

 

Each Rollup has a KB article that details what was changed

 

Now don’t worry if you haven’t been rolling up there’s no need to go through each rollup you can jump straight to rollup 6 and start from there.  The prior rollup’s are not prerequisites.

CRM MVP Frank Lee also has a good blog post talking about approaches and good practices for deploying update rollups that you can read here.

So what do you think of the rollup’s?  Are they working for you?  What would you like different?

Page 1 ... 2 3 4 5 6 ... 22 Next 8 Entries »