Skip Ribbon Commands
Skip to main content

Brite Global Blogs




Connect with Brite Global


Like us on Facebook, add us to your LinkedIn network, view our videos on YouTube or subscribe to our blog.

Facebook Linked In You Tube Blog and RSS
Apr 04
Permission accessing SSRS Report Server/Manager

Recently we have encountered an issue where a domain admin (and local admin) account was trying to access the SSRS Report Manager and Report Server web sites and was getting the following error:
User DOMAIN\UserAccount does not have the required permissions. Verify that the permissions have been grated and Windows User Account Control (UAC) have been addressed.

The easiest solution to the problem is to disable UAC on that machine (a restart will be required).
After that you should be able to access to SSRS Report Manager and Report Server web sites.

If you need to keep UAC running, the following KB article details the configuration required for the installation to both install and run SSRS:
http://support.microsoft.com/kb/934164

Jan 20
CRM 2013 Notes Control Form Presentation

CRM 2013 has a new feature that allows displaying Posts, Notes and Activities within a single control. We can easily add this new control to the form by clicking on the Notes ribbon icon on the Insert Tab of the Form Customization.

It seems that the behavior of adding the Notes control is not always the same, as sometimes the control might display only Notes and sometimes it will display the Posts, Notes and Activities.

The solution as to what the control will display can be modified, by exporting the entity, and modifying the FormXml section of the Entity within the customizations.xml file. Within the FormXml section, under forms type = "main"/systemform there is an element called FormPresentation.

The value of FormPresentation can be either 0 or 1. If the value is 0, only the Notes section will appear. If the value is 1, the Posts, Notes and Activities sections will appear. Make the required changes, re-import your entity/solution and publish your customizations and your form will display the Notes control in the proper way.

Dec 26
Using Multiple User Principal Name Suffixes

When configuring ADFS in your own local the default login of any user authenticating into the environment would be user@domain.local or something of that sort. At many times, especially when working with multiple applications, we would like the user to authenticate using different login credentials such as user@mynewdomain.com. In order to implement this, we can add suffixes that gives us the ability to user a friendly logon name that is not the same as the domain or parent's domain name.

In order to add a domain suffix to a forest, we need to follow the instructions below:

  • Log on to the domain controller, or a computer that has the different Active Directory Management Tools, and open Active Directory Domains and Trusts.
  • When the application opens, right-click on the Active Directory Domain and Trusts in the Tree window pane, and select Properties from the pop-up menu.
  • On the UPN Suffixes tab, type the new User Principal Name suffix that you would like to add to the existing forest.
  • Click Add and click OK

After the domain suffixes have been added, new users that are added to the domain can select the UPN suffix to use.

Nov 30
Setting the Security Token Expiration for IFD Claims-based Authentication

When configuring Microsoft Dynamics CRM 2011 to your Claims based Authentication a Authentication Required dialog box appears every 20 minutes.
By default the security token lifetime for claims–based authentication deployment using ADFS 2.0 (or above) is 60 minutes, however the token expiration dialog box will appear 20 minutes before the actual expiration.

When the Authentication required dialog box appears, you can either click Sign In, enter your credentials and stay connected to the session (a new security token will be issued). If you have only set Claims based Authentication and not IFD, the re-authentication will happen automatically.
If you click cancel, the token will expire as indicated. When that happens, a new browser session will need to be restarted in order to connect to Microsoft Dynamics CRM. All your data will be lost when the session expires.

In order to change the Token Lifetime from the default 60 minutes to a longer period of time, such as 2 hours or 8 hours, we can use the Windows PowerShell Adfs snap-in to configure this setting.

Follow the steps below to configure the Token Lifetime:

  1. On the Server where you have ADFS installed open a Windows PowerShell prompt
  2. Add the Microsoft ADFS PowerShell Snap-in. If you are running Windows Server 2012 R2, the snap-in is already loaded, so you can skip this step:
    PS> Add-PSSnapin Microsoft.Adfs.PowerShell
  3. Retrieve the Relying Party Token (this step is not required, but it is helpful to see the existing values):
    PS> Get-ADFSRelyingPartyTrust –Name "NAMEOFRELYINGPARTYTRUST"
  4. Change the value of the Token Lifetime by calling the Set Relying Part Trust PowerShell Command (the following command will set it to 8 hours (480 minutes):
    PS> Set-ADFSRelyingPartyTrust –TargetName "NAMEOFRELYINGPARTYTRUST" –TokenLifetime 480
  5. Close Powershell, and restart your Microsoft Internet Explorer Session and Connect to CRM. You should now be able to continue working on the application for 8 hours
Nov 01
CRM 2011 Errors with State Code or Status Code is invalid when deleting a managed solution

After importing a managed solution and making changes to the environment by removing some of the out-of-the-box views for the Contact or Account entity, we encounter an error if we ever try to delete the managed solution. The error is "State code or status code is invalid" or 1 is not a valid status code for state code…"

The solution is pretty straight forward. Before trying to delete the solution:

  • Open the default Solution
  • Navigate to the Views of the Account entity
  • Make sure that there are no system views under Inactive Views. If there are, Enable then
  • Repeat the same for the Contact entity
  • Publish your customizations

Now you should be able to delete the managed solution.

Aug 09
What’s New in CRM 2013

With the recent introduction of the next release of Microsoft Dynamics CRM 2013, originally code-named Orion and the new videos that are now available on the Microsoft Partner Training site, the future looks very interesting.

The demos that were provided were impressive and it seems like Microsoft is finally improving on the functionality that has been requested. The new User Experience included in-page experience, easier navigation, dashboards in every module and command bar instead of the ribbon. The User Experience principles that Microsoft has been trying to achieve are Simple, Usable, Modern and Fast.

Simple

Focus on the essential functions with a clear, consistent purpose that matches user intention

Usable

Measure usability, incorporate feedback into designs

Modern

Use appropriate web interpretation of Windows 8 UI to create delightful engaging people and process centric experiences

Fast

Design and deliver great perceived performance

Loved

Design for Love. Create software that people not only want to use, but simply can't live without

 

In addition to the enhanced user experience, some of the highlights we were impressed with:

  • Quick View and Quick Create Forms
  • Business Rules
  • Business Process Flows across all entities
  • Real Time Workflows
  • Mobility and Tablet Experience
  • Team Access
  • Modified Data Structure

Additional information and updates are available here

 

Aug 01
Microsoft Dynamics Online Fall ’13 Licenses

The next version of Microsoft Dynamics CRM, Dynamics CRM 2013, scheduled to be released this fall will include a new licensing scheme.
The hosted product is scheduled for release with three licensing options.

The Professional Edition will cost $65/user/month and will allow users to access the full capabilities of Dynamics CRM. Per Microsoft, this is the licensing option that will best fit most of the users' needs.

The Basic Edition will cost $30/user/month. This edition is aimed at the Sales, Service and Marketing users who need to manage accounts, contacts, leads, cases and access custom applications as well as business analysts that require reporting capabilities.

The Essential Edition will cost $15/user/month, and will provide access to custom (xRM) applications.

Users will be able to mix and match between the three license editions.

Mar 30
Detecting Duplicate Contacts

Although CRM provides a duplicate detection process that can be configured using the User Interface, many time when developing application for CRM, such as Import Manager or Synchronization application, you require to create your own duplicate detection rules, execute the duplicate detection process and retrieve the results of the duplicates from within your application.

The code samples below show how to create a Duplicate Detection Rule, execute the duplicate detection process and retrieve the results of the duplicate records.

To create a Duplicate Detection Rule, we use the DuplicateRule class, and provide a name for the rule and the entity name that will be used for the rule. In the example below, we create a rule that will check for duplicate email addresses in the contact record. After creating the rule, we need to specify the condition for the rule. The DuplicateRuleCondition class allows us to specify the attribute for the condition, and the type of rule that will be used. In the example below we use the emailaddress1 field and the base and matching attribute, and we set the match as exact match (an OptionSet value of 0).

When the rule and the rule condition have been created, we publish the rule by calling the execute method of the CRM service with the PublishDuplicateRuleRequest and PublishDuplicateRuleResponse.

Note that the process to publish a duplicate detection rule can be someone of a lengthy process, so we call the WaitForAsyncJobToFinish method to wait until the job is complete.

 

private Guid CreateDuplicateDetectionRule()

{

    DuplicateRule rule = new DuplicateRule()

    {

        Name = "Contacts with the same Email Address",

        BaseEntityName = Contact.EntityLogicalName,

        MatchingEntityName = Contact.EntityLogicalName

    };

    rule.Id = CRMHelper.xrm5.Create(rule);

 

    DuplicateRuleCondition emailCondition = new DuplicateRuleCondition()

    {

        BaseAttributeName = "emailaddress1",

        MatchingAttributeName = "emailaddress1",

        OperatorCode = new OptionSetValue(0), // value 0 = 'exact match'

        RegardingObjectId = rule.ToEntityReference()

    };

    CRMHelper.xrm5.Create(emailCondition);

 

    PublishDuplicateRuleRequest publishRequest = new PublishDuplicateRuleRequest()

    {

        DuplicateRuleId = rule.Id

    };

 

    PublishDuplicateRuleResponse publishResponse =

        (PublishDuplicateRuleResponse)service.Execute(publishRequest);

 

    WaitForAsyncJobToFinish(publishResponse.JobId, 60);

    return rule.Id;

}

 

The WaitForAsyncJobToFinish method call queries the AsyncOperation entity every 1 second to check if the process has been completed.

Once the process has been completed, the method exits and application can continue processing.

Note that since this is a lengthy process, additional code can be added in case it takes more than the maximum second value.
Normally the 60 seconds passed from the previous method is more than sufficient to create a Duplicate Detection Rule, but at times based on environment, more time will be needed.

 

private void WaitForAsyncJobToFinish(Guid jobId, int maxSeconds)

{

    for (int i = 0; i < maxSeconds; i++)

    {

        var asyncJob = service.Retrieve(AsyncOperation.EntityLogicalName,

                jobId, new ColumnSet("statecode")).ToEntity<AsyncOperation>();

 

    if (asyncJob.StateCode.HasValue && asyncJob.StateCode.Value == AsyncOperationState.Completed)

        return;

        System.Threading.Thread.Sleep(1000);

    }

}

 

The CheckDuplicateEmails method shown below is the entry point of the application. The method will first call the CreateDuplicateDetectionRule before proceeding with the running the duplicate detection process. If you already have a Duplicate Detection Rule in your environment, you can skip calling the CreateDuplicateDetectionRule method and the Delete method at the end of the method.
We create a new BulkDetectDuplicatesRequest, passing a job name, query expression that specifies the name of the entity and columns to return, a recurrence pattern and start time. The ToRecipients and CCRecipients are required fields as part of the request (if omitted, process will fail). We call the execute method passing the BulkDetectDuplicatesRequest, and get a BulkDetectDuplicatesResponse class. Since this process is also asynchronous, we will call the WaitForAsyncJobToFinish method passing the job identifier and the amount of seconds to wait.
After the Bulk Detect Duplicates process has been complete we can query the DuplicateRecord entity passing the asyncoperationid field to retrieve a list of all the duplicate contact records that were detected. The method will the return the duplicate identifiers to the calling method.
As previously mentioned, the Delete call should be omitted if you are using an existing Duplicate Detection Rule.

 

public List<Guid> CheckDuplicateEmails()

{

    Guid ruleId = CreateDuplicateDetectionRule();

 

    BulkDetectDuplicatesRequest request = new BulkDetectDuplicatesRequest()

    {

        JobName = "Detect Duplicate Contacts",

        Query = new QueryExpression()

        {

            EntityName = Contact.EntityLogicalName,

            ColumnSet = new ColumnSet(true)

        },

        RecurrencePattern = String.Empty,

        RecurrenceStartTime = DateTime.Now,

        ToRecipients = new Guid[0],

        CCRecipients = new Guid[0]

    };

 

    BulkDetectDuplicatesResponse response = (BulkDetectDuplicatesResponse)service.Execute(request);

    WaitForAsyncJobToFinish(response.JobId, 120);

 

    QueryByAttribute query = new QueryByAttribute()

    {

        ColumnSet = new ColumnSet(true),

        EntityName = "duplicaterecord"

    };

    query.Attributes.Add("asyncoperationid");

    query.Values.Add(response.JobId);

    EntityCollection results = service.RetrieveMultiple(query);

 

    var duplicateIds = results.Entities.Select((entity) => ((DuplicateRecord)entity).BaseRecordId.Id);

 

    service.Delete(DuplicateRule.EntityLogicalName, ruleId);

    return duplicateIds.ToList<Guid>();

}

 

Finally, if we need to use the duplicate identifiers that were retrieved from the CheckDuplicateEmails method, we can use the code below to display them in a grid.
The code sample below uses the Infragistics Grid, but any grid control can be used to display the results.

 

List<Guid> duplicates = CRMHelper.crm.CheckDuplicateEmails();

 

if (duplicates.Count > 0)

{

    foreach (Guid contactid in duplicates)

    {

        Entity contact = CRMHelper.crm.RetrieveContact(contactid);

 

        int rowid = dgvDuplicates.Rows.Add();

        DataGridViewRow row = (DataGridViewRow)dgvDuplicates.Rows[rowid];

        row.Cells[0].Value = contactid.ToString();

        row.Cells[2].Value = contact.Attributes["fullname"].ToString();

        row.Cells[3].Value = contact.Attributes["emailaddress1"].ToString();

    }

}

 

Mar 25
Bulk Data API ExecuteMultipleRequest in UR12

The ExecuteMultipleRequest message was added to the December 2012 Service Update (UR12) in CRM Online and CRM On-Premise, which accepts a collection of message requests, executes them in the order of the input collection and can return a collection of responses that contain the response for each message that occurred or if an error occurred. The CRM SDK version 5.0.13 is required to use the ExecuteMultipleRequest.

Each message request in the collection is processed in a separate database transaction, and the ExecuteMultipleRequest is executed by using the OrganizationService Execute method.

The ExecuteMultipleRequest behaves in the same way as if each message request in the input request collection was executed separately, except that it is processed with better performance. Plug-ins and workflow messages are executed the same way as if each execute message would be called separately.

The sample code below shows how to use the RetrieveMultiple request to retrieve multiple entity records from the database, modify theses records and update them back to the database using the ExecuteMultipleRequest.

The initial step is to instantiate the ExecuteMultipleRequest class so that any updates can be added to the class

ExecuteMultipleRequest multipleRequest = new ExecuteMultipleRequest()
{
  
Settings = new ExecuteMultipleSettings()
   {

       ContinueOnError = false,

       ReturnResponses = true

    },

    Requests = new OrganizationRequestCollection()

};


We then need to retrieve the records from the CRM database that we want to make modifications to, and make the updates. When calling the update method we are not sending the request to CRM, but only adding the update request to the ExecuteMultipleRequest requests collection:

// Retrieve records and make modifications to existing records

EntityCollection contacts = CRMHelper.crm.RetrieveContacts();

if (contacts.Entities.Count > 0)

{

   foreach (Entity contact in contacts.Entities)

    {

       Guid contactid = contact.Id;

       string emailAddress = contact.Contains("emailaddress1") ?
       contact.Attributes["emailaddress1"].ToString() : "";

       if (!string.IsNullOrEmpty(emailAddress))

       {

          contact.Attributes["xrm_profileurl"] = "http://www.contoso.com/register.aspx?eid=" +
             contactid.ToString();

          contact.Attributes["xrm_unsubscribeurl"] = "http://www.contoso.com/communications.aspx?eid="
             + contactid.ToString();

          UpdateRequest request = new UpdateRequest

          {

             Target = contact

          };

          // Add each updated record to the Multipe Request requests collection

          multipleRequest.Requests.Add(request);

       }

    }

}


Finally after making the updates to each record, we will call the Execute method on the ExecuteMultipleRequest class to retrieve the responses of all the updates.
We can then loop through the responses to verify that each record update was either successful or failed.

// Execute the multiple requests

ExecuteMultipleResponse multipleResponse = (ExecuteMultipleResponse)CRMHelper.xrm5.Execute(multipleRequest);

 

// Individual Responses and Faults

foreach (ExecuteMultipleResponseItem responseItem in multipleResponse.Responses)

{

   string fullname = ((Contact)(multipleRequest.Requests[responseItem.RequestIndex])
    .Parameters["Target"]).FullName;

   if (responseItem.Response != null)

      Console.WriteLine(String.Format("Contact {0} updates with profile information", fullname));

   else if (responseItem.Fault != null)

      Console.WriteLine(String.Format("Contact {0} could not update. The following error was
returned: {1}", fullname, responseItem.Fault.Message));

}

 

Feb 02
Choosing CRM Connection Option

Many CRM application that are written for Microsoft Dynamics CRM require to atuneticate a user with any Microsoft Dynamics CRM deployment. This sample in this article demonstrates how to connect and authenticate a user with Microsoft Dynamics CRM On-Premise or Microsoft Dynamics CRM Online (using both Windows Live Id and Office 365 credentials).

The code example below contains three methods.
A public class method that establishes the connection, and two private methods to retrieve the Authentication Credentials and retrieve the Organization Service Proxy.

The following is the list of references, variables and properties that are required for this implementation to work.

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Client.Services;

 

public static OrganizationServiceProxy service;
private static string UserName { get; set; }
private static string Password { get; set; }

 

The ConnectToCRM creates a new OrganizationServiceProxy class that allows performing operations against all of the Microsoft Dynamics CRM environments.
The method retrieves the specified credentials and established the OrganizationServiceProxy class connection by calling the GetProxy method.

The serviceUrl contains the Uri of the CRM Services and the provider contains the type of provider that is going to be used to connect to CRM.
There are 5 options for the AuthenticationProviderType: Active Directory (1), Federation (2), Live Id (3), Online Federation (4) and None (0).

public static void ConnectToCRM(Uri serviceUrl, AuthenticationProviderType provider)
{
  
IServiceManagement<IOrganizationService> orgServiceManagement =
      
ServiceConfigurationFactory.CreateManagement<IOrganizationService>(serviceUrl);

   AuthenticationCredentials credentials = GetCredentials(provider);
  
service = GetProxy<IOrganizationService, OrganizationServiceProxy>
     
(orgServiceManagement, credentials);
  
service.EnableProxyTypes();
}

 

The GetCredentials method returns an AuthenticationCredentials class contains the credentials of the CRM user based on the environment that they are connecting to. This method shows the implementation for Active Directory, CRM Online using Windows Live Id and CRM Online using Office 365.    

private static AuthenticationCredentials GetCredentials(AuthenticationProviderType provider)
{
  
AuthenticationCredentials credentials = new AuthenticationCredentials();
  
switch (provider)
  
{
     
case AuthenticationProviderType.ActiveDirectory: // Active Directory      
        
credentials.ClientCredentials.Windows.ClientCredential =
           
new NetworkCredential(UserName, Password);
        
break;
     
case AuthenticationProviderType.LiveId: // CRM Online using Live Id             
         credentials.ClientCredentials.UserName.UserName = UserName;

         credentials.ClientCredentials.UserName.Password = Password;
        
credentials.SupportingCredentials = new AuthenticationCredentials();
         credentials.SupportingCredentials.ClientCredentials =
 
            Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();

         break;
     
case AuthenticationProviderType.OnlineFederation: // CRM Online using Office 365
         
credentials.ClientCredentials.UserName.UserName = UserName;
         credentials.ClientCredentials.UserName.Password = Password;
        
break;
     
default:
        
credentials.ClientCredentials.UserName.UserName = UserName;
         credentials.ClientCredentials.UserName.Password = Password;
        
break;
   }
   return credentials;
}

 

The following is a generic method that is used to obtain the discovery and organization service proxy.
The TService parameter is used to set the IDiscoveryService or IOrganizationService type to request the resepective service proxy instance.
The method will finally return either the DiscoveryServiceProxy or the OrganizationServiceProxy based on the TService type.

private static TProxy GetProxy<TService, TProxy>
(IServiceManagement<TService> serviceManagement,
AuthenticationCredentials authCredentials)
where TService : class           
where TProxy : ServiceProxy<TService>
{
  
Type classType = typeof(TProxy);
  
// Obtain service proxy for Windows LiveId and Office 365 environments. 
  
if (serviceManagement.AuthenticationType != AuthenticationProviderType.ActiveDirectory)
  
{
     
AuthenticationCredentials tokenCredentials = serviceManagement.Authenticate(authCredentials);
     
return (TProxy)classType
        
.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(SecurityTokenResponse) })
        
.Invoke(new object[] { serviceManagement, tokenCredentials.SecurityTokenResponse });
   }

// Obtain service proxy for ActiveDirectory environment.         
  
return (TProxy)classType
  
.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(ClientCredentials) })
  
.Invoke(new object[] { serviceManagement, authCredentials.ClientCredentials });
}

 
Once the connection to Microsoft Dynamics CRM is established, you can call any of the CRM WCF Service methods calls.
This example was created using the CRM 2011 SDK version 5.0.13 (published 1/7/2013).

1 - 10Next

 About this blog

Welcome to the  Brite Global Blog. Here you will find content related to new and existing technologies, company, news and events.
Powered By SharePoint 2013