Additional PowerWebForm Plug-in Now Available for Dynamics CRM

The PowerWebForm plug-in is one of twenty awesome PowerPack add-ons that provide additional functionality to both CRM 2011 and CRM 2013. This add-on lets CRM users create web forms inside of CRM, post web forms to their website, and pulls form data automatically back into CRM as soon as that form is submitted. As a part of PowerWebForm, the CRM user can choose what happens with that data when it comes back into CRM – do you want to create a lead? A case? Some other custom entity? The choice is yours!

If you've chosen to create contacts when your PowerWebForm is submitted, maybe it would also be useful for you if an account was automatically created and related back to that contact as well. If that's the case, then boy do we have news for you! PowerObjects has created a plug-in that marries up beautifully with the PowerWebForm add-on, and will automatically create an account (or find a related account that's already in your system) when a contact is created in Dynamics CRM.

Once you've imported the PowerWebForm add-on into your CRM system, and you've imported this additional plug-in, the first thing you'll want to do is create a new field called Company Name (text) and place that field on your contact form. The field can be hidden, if you don't want users to get this field confused with the Company Name lookup that is on the contact record by default.

Additional PowerWebForm Plug-in Now Available for Dynamics CRM

You will then want to build a web form that creates a contact when it's submitted by choosing Contact in your related entity field on your web form. Make sure you ask for the person's company name and email address when you're creating form fields. Map the Company Name field on the web form to the Company Name (text) field that you just created for your contact record, and map the email address field on the web form to the email address field on the contact. Then continue to build the rest of your form fields as you normally would.

Additional PowerWebForm Plug-in Now Available for Dynamics CRM

Here's how the logic works:

When a web form is submitted, the PowerWebForm solution will automatically create contacts in your CRM system. On the creation of a contact record, the custom plug-in will run and create a related account record.

This plug-in will run on the creation of any new contact in your system (whether manually created or created through a web form submission).

If the contact has an existing parent account related to the record, nothing will happen

If the Company Name text field is filled in (on the contact entity), the plugin will search for the company name in your CRM system. If an exact match is found it will use this for the parent account.

If not, the plug-in will search for other contacts with the same @xxxx.com email domain that have a parent account. If one is found, the plug-in will use that related parent account as the parent account for the new contact record.

Otherwise, the plug-in will create a new account with simply the company name and it will set that as the contact's related parent account.But wait, there's more! This handy plug-in will run not only if the contact is created from a web form, but also if you manually create a contact, and fill in the Customer Name (text) field.

Interested in trying this plug-in out? Download the PowerWebForm add-on and contact PowerObjects to get this free plug-in for your CRM system!

Happy CRM'ing!

Sitemap Error After Removing a Managed Solution from CRM 2011

Greetings, fellow CRMers! After removing a managed solution, have you received the following error when attempting to login to the CRM website?

Removing a Managed Solution

If you have, look no further for the solution.

This particular error is due to a leftover sitemap reference to a deleted entity. Keep in mind that CRM will normally remove all references from the sitemap when removing a solution. If CRM is unable to do so, it will throw an error and prevent the solution from being removed. However, instances have occurred where this is not the case when removing a managed solution.

Here's how to remedy a situation like this step by step:

  1. Download the SiteMap Editor Tool which is part of the XRM Toolbox from CodePlex: http://xrmtoolbox.codeplex.com/
  2. Once you have downloaded and extracted the above tool, you will see a screen like the one shown below.Removing a Managed Solution
  3. Within the above window, click on SiteMap Editor.Removing a Managed Solution
  4. For the purposes of this demonstration, let's say you want to connect to a CRM On-Premise organization. However, this tool also works with CRM Online. Enter in the server name and login information and then click Get Orgs. Select the organization from the drop-down and click OK.Removing a Managed Solution
  5. Once the tool connects, click Load SiteMap.Removing a Managed Solution 
  6. Important! Make sure you back up a copy of your sitemap before you edit it. Once you have clicked Load SiteMap, you will have an option to save a copy of the sitemap locally. Please click Save SiteMap before editing it.Removing a Managed Solution
  7. Once you have saved a copy locally of the sitemap, you can then proceed to remove the leftover reference. In this instance, I created a test reference to highlight how to locate the leftover sitemap entity reference and named it reference AATest. Once I located the SubArea in question which references the entity that no longer exists, I clicked Delete. After I have confirmed that the entity was not referenced in any other areas or groups, I published the changed by clicking Update SiteMap.

Removing a Managed Solution

After reloading refreshing the browser, the sitemap was able to load properly and I was able to login to CRM as usual.

If you want to know how to modify the sitemap without using the tool mentioned above, check out our blog All About Sitemap Editing in CRM 2011. If you need any additional help with the above steps or would like us to fix it for you, please do not hesitate to reach out to our support staff.

Happy CRM'ing!

Table Merge Error with Upgrading a 2011 Organization Database to CRM 2013

In Microsoft Dynamics CRM 2013, there has been a significant change to the database structure in that there are no longer EntityBase and EntityExtensionBase tables. Now there is just one entity table for a given entity. With this change, those who are upgrading an existing organization will eventually need to go through the process of merging the Base and Extension tables—either at the time of upgrade or at a later date.

As a result of this change, one of the issues that comes up while importing a CRM 2011 organization database to a new 2013 deployment (using the Organization Import feature of the Deployment Manager) is a table merge error stating: "This may exceed that the architectural limits of Microsoft SQL Server, and the merge operation will fail."

The steps below will help you resolve this issue.

1. While importing an organization for upgrade to CRM 2013, the validation checks show the following error:
Table Merge Error

The fix is to decrease the number of columns in the source CRM system. This has to do with a view limitation in SQL server.

Note: Due to the architecture change, if you are hitting this limit 'by just a little bit', defer the table merge until later and try via the command line.

2. Cancel the import and defer the Table Merge in the following way, as noted in the CRM 2013 upgrade instructions:

How to Defer Table Merge

Install CRM, but do not upgrade any orgs.

Create a new reg key. Location: HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSCRMMergeBaseExtensionTables

Type: Dword (32-bit)

Value: 0

3. Restart import and complete.

4. At this point you need to find out what columns on that table can be deleted. Then you should be able to run the merge manually, as after the upgrade there will be a few less columns due to the new architecture of CRM 2013.

5. Follow the steps below using the merge tool that comes with the CRM 2013.

a. Set that registry key mentioned above in step 2 to 1 first (so CRM will run the merge).

b. Run the following statement at command prompt on CRM Front End server to merge the tables that have merge issues (the ones that stated issues in the import in step 1 above). Replace the names appropriately for highlighted parameters:

CrmMergeBaseAndExtensionTableTool /s:databaseservername /o:<databasename> /e:entityname  /log:c:crmmergetoollog.txt

c. Repeat step 2 for all the entity tables with merge issue. The error in the import from Deployment Manager might still remain. In this case, run the rest of the merge for the whole database with the following command:

CrmMergeBaseAndExtensionTableTool /s: databaseservername /o:< databasename > /log:c:crmmergetoollog.txt

This should take care of the merge error, and importing the database should go smoothly at this point.

PowerObjects encourages customers to complete this merge as quickly as possible. NOT completing this step in the upgrade process may prohibit future updates.

You can learn more about CRM 2013 features and functions or sign up for a CRM 2013 upgrade training on our website.

Happy CRM'ing!

Downloading the Outlook Client for Microsoft Dynamics CRM 2011

You’ve probably heard that Microsoft Dynamics CRM 2013 is here, and that it comes with a lot of great features. That being said, many organizations will remain on the CRM 2011 platform for a variety of reasons—particularly if their CRM systems are highly customized.

If you’re one of those organizations that will be running CRM 2011 for the foreseeable future, it’s likely that you or another CRM user will want to download the Outlook Client for CRM 2011. Microsoft has made this very easy to do by adding a yellow bar below the ribbon prompting users to get the Outlook client.  (It’s pretty easy to permanently dismiss this message, by the way.)

Downloading the Outlook Client for Microsoft Dynamics CRM 2011

However, as of the release of MS Dynamics CRM 2013, that link will prompt you to download the 2013 Outlook Client, which can’t be configured to point to a 2011 CRM instance.

Good news! It’s still really easy to download the 2011 Outlook Client on the Microsoft website.  Once you’ve downloaded it, you can refer to our blog on how to install Dynamics CRM for Outlook.

Happy CRM’ing!

Create and Register an Event in the CRM 2011 Customer Portal

In a previous blog, we explained how to update the customer portal within CRM 2011. Today you will learn how to use the customer portal to create and register an event in CRM 2011.

To create an event in CRM:

  1. Go to the CRM Marketing section and under the Campaigns section, click New.
  2. Make sure to set the Status Reason to Registration Open so that users will be able to access the portal to register for the event.

    Create and Register an Event

  3. Make sure to check the box for Publish Event Details on Web and set the Campaign Type to Event. Fill out any other necessary information.

    Create and Register an Event in the CRM 2011 Customer Portal

  4. Save the event.

How to register the event in the customer portal:

  1. Go to the Customer Portal and click on Recently Added:

    Create and Register an Event in the CRM 2011 Customer Portal

    Or click on Upcoming Events:

    Create and Register an Event in the CRM 2011 Customer Portal

  2. Click Registration Open:

    Create and Register an Event in the CRM 2011 Customer Portal

  3. You will see:

    Create and Register an Event in the CRM 2011 Customer Portal

  4. Click on Register for this Event:

    Create and Register an Event in the CRM 2011 Customer Portal

  5. The registration form will open. Fill out the registration information:

    Create and Register an Event

Now you know how to create and register an event in the CRM 2011 Customer Portal. For more helpful guides check out our blog!

Happy CRM'ing!

Redirecting to Dynamics CRM Mobile Site in IE 11

Recently, Microsoft released Internet Explorer 11 (IE11), the newest version of its web browser. Depending on your settings, this update may be installed automatically on your computer.

One thing you may notice when you upgrade to IE11 is that you are redirected to the mobile site for Microsoft Dynamics CRM.

Redirecting to Dynamics CRM Mobile

The reason for the redirect is that IE11 does not import settings from the previous version of Internet Explorer. However, this can be fixed quickly by adding the domain of your CRM site into the list of sites to view in compatibility mode. Here's how:

  1. Click the gear in the top right of IE and then select Compatibility View Settings.

Redirecting to Dynamics CRM Mobile Site in IE 11

  1. If you are already at your CRM web URL, IE will automatically populate the domain. You can just click the Add button.

Redirecting to Dynamics CRM Mobile Site in IE 11

  1. Once you have added the domain, refresh your browser and you will be redirected to the main version of the site, just like before the upgrade to IE11.

For more information on optimal IE settings for CRM, check out our previous post Configuring Settings for IE10 and CRM. You can also find out more about what Internet Explorer 11 has to offer in the official TechNet article.

Happy CRM'ing!

Dynamics CRM Email Router Troubleshooting 101 – Outgoing Emails

One of the great features of Microsoft Dynamics CRM is the ability to send out automatic notification emails triggered by certain actions, such as creating an account, closing a case, adding a note to a case, or converting a lead. This is done using the email router. So what happens when you have a CRM environment with a working email router setup, and then something breaks? Instead of simply restarting the server (which may fix the problem), you would be better off to first identify the real issue. This Dynamics CRM email router troubleshooting guide will show you how to troubleshoot step-by-step a previously working email router environment, configured for outgoing emails.

Step 1: Determine if there is a problem with sending emails from CRM

Issues that stem from the email router may be reported with only vague details. For instance, you could have user call to say that "emails are not working," and you will have to determine whether the problem is specific to your CRM email router, Microsoft Outlook, Microsoft Exchange, or something else.

Let's say, for example, Mike calls the help desk to with an issue where a work order was generated in CRM, but Bob was not notified. In this case, Mike is counting on a workflow to an automatically email to specified users when a work order is created or changed. If Mike is an advanced user, he might recognize the issue and ask, "Can you check the email router? It doesn't appear to be sending out emails." But that might not be the case with everyone.

No matter how the issue is first brought up, the thing to you need to determine first is whether the issue is related to emails coming out of CRM. Sometimes other things can be confused with an email router problem, such as networking, Outlook (offline mode, junk folder), or Exchange (password change, email address change). So first you'll want to check whether the user still has network connectivity and is still receiving emails.

Step 2: Determine if the issue is specific to just one user, or across all users.

There are two different paths for troubleshooting a user-related issue depending on whether it affects just one user or the whole organization, so you'll want to determine that right away. There are two quick ways to determine this:

The second method is preferred, since it cuts down on additional variables that could be causing the issue. For example, the asynchronous service could stop working, and your users may not be able to tell if they are testing it all the same way—by creating a record that triggers a workflow that sends an email. If the async is down, no emails will be generated, even if the email router is functioning correctly.

If you can successfully send and receive an email activity manually created within CRM, it's likely a user issue. Proceed to step 3. Otherwise, go to step 9, since it is likely a server issue instead.

Step 3: If you've determined this is a use-related issue, check whether the user's outgoing profile is set to "email router."

Go to Settings > Administration > Users, and open the specific user who reported the issue. Scroll down to a dropdown box called "E-mail access type – Outgoing." If it is not already set, change it to e-mail router and save the record.

Dynamics CRM Email Router Troubleshooting 101 – Outgoing Emails

Step 4:
Check whether the user has Approve access.

You should still be in the user record from the last step. In the ribbon, click Approve E-mail. Once this is done, give it at least a few minutes to determine if emails are coming through.

Dynamics CRM Email Router Troubleshooting 101 – Outgoing Emails

Alternatively, you can remove the requirements for having to approve emails for all users and/or queues. You can do this by going into Settings > Administration > System Settings, and in the email tab, "Process emails only for approved users/queues."

Dynamics CRM Email Router Troubleshooting 101 – Outgoing Emails

Step 5: Check if the email activity exists in CRM.

To find the corresponding email that was supposedly created in CRM that the user claims he or she did not receive, start an advanced find and change "Look for:" to email messages.

Under the criteria, select Direction Equals Outgoing.

Dynamics CRM Email Router Troubleshooting

Now click on Results in the ribbon.

Once you have the list of outgoing email activities in CRM, click on the Modified On column to sort, then search for the email that the user did not receive. You may also want to specify additional criteria in the advanced find to further narrow it down.

If the email activity does not exist, then the problem is not the email route. Instead, it's likely a failure in the process or a user-related error within CRM, such as:

If the email activity does exist, you'll need to examine the status reason of the email activity. Proceed to the next step.

Step 6: Does the Status Reason show as Sent?

If the status reason shows as sent, that means the email router successfully sent the email through SMTP or Exchange, and the issue most likely lies outside of the email router.

Step 7: Does the email activity show as Sending?

An email activity should only be in sending status for a short time. If it is in perpetual sending mode, you may see the "Number of delivery attempts" repeatedly going up (ideally, this number should not be higher than 1.) You'll need to verify that the sender of the email has access to the server sending the emails. Also check the error logs on the email router server to determine if a specific reason is causing it to fail.

Step 8: Does the email activity show as Pending Send?

An email activity in pending send is one that does not have a means to be delivered, which could mean various things. Since we have already checked that the user reporting the issue is set to use the email router, we should double check that the sender of the email has that set as well.

Open the email activity and check the sender of the email. Whether it is a queue or a user, it should have outgoing set to email router and access approved. See steps 3 and 4 on how to set this.

If the email was generated from a workflow where the owner of the workflow is different than the sender of the email, then the sender needs to have all emails on your behalf set.

  1. Login to CRM as the sender of the email.
  2. Go to File > Options.

    Dynamics CRM Email Router Troubleshooting 101 – Outgoing Emails

  3. Go to the email tab and check "Allow other Microsoft Dynamics CRM users to send e-mail on your behalf."

    Dynamics CRM Email Router Troubleshooting

    Note: it may be beneficial to have this setting for all users. Since having every user log in to CRM to change their personal options can be tedious, you can update all users at once through two different methods. If you have direct data base access, you can run a SQL update query, in the orgname_MSCRM database:

    update usersettings

    set issendasallowed = 1

    If you are using CRM Online, or do not have database access, you can also set this setting by downloading the user settings utility, available free from Codeplex. This allows you to manage user settings, including the allow email setting, through a web interface.

If the email activity is still in pending send status after these steps, login to the email router server, open the email router configuration, go to the tab for "users, queues, and forward mailboxes," and click load data. Check if the sender of the email appears in the list, then click Test Access. Make sure it succeeds. Then click the Publish button, and see if the email gets sent. If not, proceed to the next step.

9) Check the email router service.

First, check if the service "Microsoft Dynamics CRM Email" is running. If not, then start the service. If the service does not start, check if it is running under a service account, and if so, update the password to make sure it is correct. You may also try running the service as local system.

If this is not the case, then go to the following folder: C:program filesmicrosoft dynamics CRM EmailService

Rename the file Microsoft.Crm.Tools.EmailAgent.SystemState.xml to something else (like .old). Then attempt to restart the service.

Note: If you have incoming profiles set up, there are further considerations to take before renaming this file, since it keeps track of the last threshold date. Essentially, if this date is lost and you have queues setup, all previous emails will be re-created in CRM.

If it still doesn't start, it is possible the config file is corrupt. Sometimes this happens after a rollup update, but it is not a common error. To fix it, rename the following file to something else: Microsoft.Crm.Tools.EmailAgent.xml. Then run a repair on the email router installation, which will recreate that file, and attempt to start the service again.

10) Test access to the organization.

If the service is running correctly, open the email router configuration, go to the tab for "users, queues, and forward mailboxes," and click load data. If you receive an error message, verify that the account specified in the deployment can successfully login to the organization.

For on-prem environments, the quickest way to check is in the deployments tab. Open the configured deployment and copy and paste the URL into a browser, still on the email router server, while logging in as the user specified in the deployment.

If you cannot login, then verify that the user still has access, along with the system administrator security role. Possible reasons for failure to connect are:

If you can login through a browser, check if the user is in the privUserGroup security group, within active directory.

For CRM Online, attempt to login through the regular CRM URL in the email router server. Some possible reasons why it would suddenly fail to stop working are similar to an on-prem environment. A change in the deployment configuration could be a migration from CRM Online Live-ID to Office 365, in which the discovery URL changes.

One last thing to check is if you can still create a discovery service. You can test this by going to Settings > Customization > Developer Resources, and click on the URL below discovery service. This will bring up a new page that starts with "DiscoveryService Service" at the top. Click on the link at the top, just to the right of svcutil.exe, which should bring up an XML page. If you see a 500 error in the XML, then the Discovery service needs to be repaired before the email router will start working. As a quick fix, try an iisreset on the front end application server.

11) If you can successfully load data, then click on test access.

If an error message is received, verify that the connection to the SMTP server is still valid with correct access, and that the SMTP service is running. The error messages here are usually very accurate, and will say the exact error (such as unable to relay, impersonation failure, etc.)

If access is succeeding but no emails are being sent, there are two things to check:

12) Additional considerations.

If you've gone through these steps and are still having trouble, consider having PowerObjects help provide some support. We're happy to help!

Happy CRM'ing!

Rounding Numbers In Microsoft Dynamics CRM

In elementary school math classes, we were all taught how to round numbers. When given a value of 11.725 and rounding to 2 places, we know to round up to 11.73. Microsoft Dynamics CRM also does rounding for areas that use math, such as calculating the totals on quotes, orders, and so on. However, given the value of 11.725, the rounding in CRM will produce 11.72.

Normally, a user would never notice this, as the system rounds consistently in all areas, but if you're doing some rounding with some JavaScript functions, you may notice that sometimes your values are off by a penny! This is because CRM uses the .NET function System.Math.Round, which produces a rounding variant known as "banker's rounding."

What this means is that for the middle value (anything ending in 5) the system rounds the number to the nearest even number. Let's consider some examples:

The banker's rounding only applies for values ending in 5, so 6 and above will still always round up (0.226 rounds to 0.23) and 4 and below will always round down. The idea here is that if you consistently round 5 up, over time you will skew your numbers higher than they actually are. Banker's rounding attempts to mitigate this by pseudo-randomizing the rounding in an attempt to stay closer to "true" over many rounding operations over time.

Additional information on the rounding used in CRM can be found here, with extra information on various rounding techniques here.

As JavaScript uses "Arithmetic Rounding" and has no built-in "banker's rounding," we can use the below custom JavaScript function to implement banker's rounding:

function bankersRounding(num, decimalPlaces) {

var d = decimalPlaces || 0;

var m = Math.pow(10, d);

var n = +(d ? num * m : num).toFixed(8); // Avoid rounding errors

var i = Math.floor(n), f = n - i;

var r = (f == 0.5) ? ((i % 2 == 0) ? i : i + 1) : Math.round(n);

return d ? r / m : r;

}

That's all there is to it. We hope you enjoyed reminiscing about those grade school math classes! As always, if you need help, the experts at PowerObjects can help.

Happy CRM'ing!

Optimizing Sales Pipeline Probability Criteria in Dynamics CRM Opportunities

Many sales organizations use sales pipeline probability percentages to help them understand where sales opportunities are at in the sales cycle and what the chances are of closing the deal. Understanding some best practices for success with sales pipeline probability criteria can help you get the most out of this feature.

The probability percentage field can be found on the opportunity record in in Dynamics CRM 2011. This field can be configured to use an organization's defined sales pipeline criteria and processes. To get the most value out of this feature, organizations must determine what the criteria should be. Good, measurable criteria should use the following guidelines:

  1. Only create the number of stages in the sales cycle that really indicate major milestones in the sales process and that are repeated at least 80% of the time.If you have never had set pipeline criteria before, the key is to keep it as simple as possible. You can expand it after you roll it out to the sales team and have a chance to learn from using it in the field. There will always be those few deals that are the exception, but the 80/20 rule definitely applies here.
  2. For each stage, define what steps or actions need to happen to set the opportunity stage at each defined percentage.For example, if you have a set stage of "Prospect Qualified 30%," you need to create a set of defined actions that must occur before a sales person can set an opportunity at that stage. This could be something such as in in-person meeting has occurred, the prospect is interested in moving forward, and/or the prospect need has been clearly defined.This gives the sales person clear direction on what is expected if they set the stage to status, so they don't just set it based on how they feel that day or what kind of weekend they just had. It also gives the sales manager a clearer picture of where the opportunity is at and what has occurred when they follow up with the salesperson about the opportunity.

Sample Pipeline Criteria

Using the guidelines above, here is an example of a simple pipeline criteria to get started with:

10% Suspect Identified

Rules: Potential customer identified and an in-person meeting has been scheduled.

30% Prospect Qualified

Rules: In person meeting has occurred, prospect interest in product/service verified, prospect needs identified and verified

50% Proposal Sent

Rules: Proposal/quote has been sent and reviewed with the prospect.

90%: Contract sent

Rules: Proposal/quote signed by prospect, contract sent for signature.

Configuring CRM to Use Sales Pipeline Probability

Now, let's configure Microsoft Dynamics CRM so that we can use this criteria track sales opportunities.

  1. Create a custom option set (drop down) field in the Opportunity form to place your pipeline values and replace the system probability field CRM provides. (You could use the system field for this, but it is a simple text field and you risk that your sales team will enter data incorrectly or inconsistently. For best practices on creating options sets, check out our blog When to Use a Global Option Set vs. a Custom entity.) Here what it should look like when you're finished:

    Optimizing Sales Pipeline Probability Criteria in Dynamics CRM Opportunities

    Now your sales team can mark their opportunities at the appropriate stage.

  2. You can create dashboards for analytics using new field. If you haven't created a dashboard before, our blog How To Create a Personal Dashboard in CRM 2011 is a great place to start. Here's an example of a dashboard using the criteria we established above:

Optimizing Sales Pipeline Probability Criteria in Dynamics CRM Opportunities

Once you have set clearly defined and realistic pipeline percentage criteria, it can be a very powerful predictive sales analysis tool!

Happy selling & CRM'ing!

Microsoft Dynamics CRM-Driven SharePoint Security

Microsoft Dynamics CRM supports out-of-the-box integration with SharePoint, described in detail two previous blogs: SharePoint Integration in Microsoft Dynamics CRM 2011 and CRM 2011 and SharePoint 2010: Configuration and Folder Structure.

One of the features of out-of-the-box integration is that the folders are created as needed—that is, when user navigates to Documents area of the record for the first time.

This is a usually a good approach, but this method can have shortcomings in some more complex requirements, such as:

Out-of-the-box integration will create a folder using the configured structure, using the name of the record:

Microsoft Dynamics CRM-Driven SharePoint Security

In SharePoint, the security is inherited from parent folder:

Microsoft Dynamics CRM-Driven SharePoint Security

Microsoft Dynamics CRM has robust security architecture, with business units, teams, roles and sharing. In the out-of-the-box SharePoint integration, users that cannot view a record in CRM would be able to view the documents directly in SharePoint.

You could maintain the security manually in SharePoint, but this can become cumbersome with large number of records. Also, SharePoint is often considered as an invisible add-on where users only use the CRM interface. Ideally, you want to programmatically mirror the CRM security in SharePoint.

Our approach to solving this is to use Dynamics CRM plug-ins and create SharePoint folders programmatically, break the inheritance, and add permissions where needed.

Here's the basic functionality of the plug-in:

At this point, all you've done is duplicate the out-of-the-box integration and force it to run at the creation of the CRM record.

The big challenge now is that the required functionalities, BreakRoleInheritance and RoleAssignments, are not available through SharePoint 2010 web services. You'll have to use SharePoint Client Object Model, which requires that the code must reference to Microsoft.Sharepoint.Client.dll and Microsoft.Sharepoint.Client.Runtime.dll. This means the assemblies must be deployed to the CRM server GAC and the plug-in cannot be isolated. Therefore, this approach is not applicable for CRM Online. For CRM Online, you may use similar code, but create your own web service that the isolated plug-in can call.

Here's a step-by-step approach to breaking inheritance and adding access to a specific SharePoint group:

1. Set Client Context and find the List:

ClientContext clientContext = new
ClientContext(site);

clientContext.Credentials = new
NetworkCredential(_connectionInfo["Username"], _connectionInfo["Password"], "");

List oList = clientContext.Web.Lists.GetByTitle(listname);

2. Use CAML Query to find specific folder using URL:

CamlQuery query = new
CamlQuery();

query.ViewXml = "<View Scope='RecursiveAll'><Query><Where><Contains><FieldRef Name='FileRef'/><Value Type='Lookup'>"+FolderURL+"</Value></Contains></Where></Query></View>";

ListItemCollection collListItem = oList.GetItems(query);

clientContext.Load(collListItem);

clientContext.ExecuteQuery();

3. If ListItem found, we can break the inheritance:

oListItem.BreakRoleInheritance(false,true);

4. If you want to add certain access to a group, we can do that against ListItem as well. Here is how to add the Contributer role to a group:

RoleDefinitionBindingCollection collRoleDefinitionBinding = new
RoleDefinitionBindingCollection(clientContext);

RoleDefinition oRoleDefinition = web.RoleDefinitions.GetByType(RoleType.Contributor);

collRoleDefinitionBinding.Add(oRoleDefinition);

oListItem.RoleAssignments.Add(siteGroup, collRoleDefinitionBinding);

clientContext.ExecuteQuery();

With this plug-in, as soon as record is created, the folders are created and security is set:

Dynamics CRM-Driven SharePoint Security

Note that all the items including the subfolders underneath this folder will inherit the permissions from this folder, so you generally only have to do this at one point of each branch.

Microsoft Dynamics CRM-Driven SharePoint Security

Extending from these basic building blocks, you can build a robust, CRM-driven security architecture in SharePoint.

If you want more information regarding CRM and SharePoint Integration, make sure to check also our other blogs:

Happy CRM'ing!

Are You Missing Completed Workflows in CRM 2011?

Workflows are a powerful tool that CRM users utilize to create records, update records, send emails and much more. With a recent update to Microsoft Dynamics CRM, a new option was added to the administration tab that allows users to "automatically delete completed workflow jobs (to save disk space)."

automatically delete completed workflow jobs - CRM 2011

So what does this mean?

When you check this option, it will remove the system job as soon as it has been marked complete, and your completed workflows will appear to be missing. This could cause issue with auditing or troubleshooting a workflow as well as present issues with performance.

To avoid these issues, PowerObjects recommends that you leave this option unchecked and schedule a system job on either a weekly or monthly basis to remove these completed job records instead.

For more on workflows and how to use them, here are some additional blogs:

Happy CRM'ing!

Passing Parameters Between Forms in CRM 2011

Did you ever wish you could scoot some data from one form to another and then immediately start working on the new record? If so, then maybe passing parameters from one form to another in a query string is the answer for you!

In this example we will open a new email from the Account form with a function that will pass parameters to the form so we can use them on the email form.

Let's start on the Account form. Here is a small function that gets the GUID for the Account record, sets it as the parameter "accountid_0" and then uses the openEntityForm function to open the email form.

//Function to open another entity's form

function NewEmail()
{
 var parameters = {};
 var accountid = Xrm.Page.data.entity.getId();
  parameters["accountid_0"] = accountid;

Xrm.Utility.openEntityForm("email", null, parameters);
}

This small function can be added to a button or to an event on the form. In our example I will simply add it to the OnSave event.

passing parameters between forms in CRM 2011

On our Email form I am going to set up some events to read the query string, grab the value for "accountid_0" and then show it in a message box. I'll add the "formonload" function to our Form Load event.

//Function to read the QueryString

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[[]/,"[").replace(/[]]/,"]");
  var regex = new RegExp("[?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
function formload()
{
if (getQuerystring('accountid_0') != "")
{
    var accountid = getQuerystring('accountid_0');
    accountid = accountid.substr(3,32);
    alert(accountid);
}
}


Now let's go over to an Account record, save some data, and we should get a new email message form and a message box with the Account GUID. Ready?

Oh no! What happened? We can see that we've got the email form here, the ribbon is looking good. But what is this error?

We can see this is a CRM Online Organization that has been updated to UR12 which gives us a clue*. According to this MSDN article we've missed a step. We need to revisit our Email form and set it up to accept our custom parameter.

*Interesting to note, the configuration works fine in an on-premise CRM organization running UR8.

You can set custom parameters in the Form Properties right on the Parameters tab. Since AccountID is a GUID, I am going to give it the type of UniqueID, but you can see there are a number of options here to work with.

We'll name the custom parameter "accountid_0" and set the Type to UniqueId. Save, Publish, and let's try it again.

Looks like we have a winner! Now that we have the account ID accessible from the email entity form, there are any number of things we could do.

Maybe you'd like to use an oData query to get some other data from records related to the Account and pre-populate the subject of the email or even parts of the body.

Maybe you'd like to pass more parameters in the query string and use them to set a few values.

Maybe you'd like a chocolate shake? Wait, I suppose you could use CRM to email someone to ask for one, but why not celebrate your victory with a trip to the ice cream shop? Sounds like a great idea to me.

Enjoy and happy CRM'ing!