Tuesday 7 May 2013

Create Web Application for CRM online

how to create early bound entity class

example:

CrmSvcUtil.exe /url:https://opcare.api.crm5.dynamics.com/XRMServices/2011/Organization.svc /out:Xrm.cs /username:"admin@opcare.onmicrosoft.com" /password:"Welcome1234" /namespace:Xrm /serviceContextName:XrmServiceContext /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"

reference:
http://msdn.microsoft.com/en-us/library/gg327844.aspx

easy step to follow

1) Add the generated .cs code to the solution

2) Add the deviceidmanager.cs. located at sdk/samplecode/helpercode/

3)  Add the following references from the SDK\bin folder.
  • AntiXSSLibrary.dll
  • Microsoft.Crm.Sdk.Proxy.dll
  • Microsoft.Xrm.Client.dll
  • Microsoft.Xrm.Portal.dll
  • Microsoft.Xrm.Portal.Files.dll
  • Microsoft.Xrm.Sdk.dll
  • Microsoft.identitymodel.dll
  
  • Microsoft.Data.Entity.dll
  • System.Data.Services.dll
  • System.Data.Services.Client.dll
  • System.Runtime.Caching.dll
  • System.Runtime.Serialization.dll
  • System.Security.dll

  • 4) add the library
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Runtime.Serialization;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Messages;
    using Microsoft.Crm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Client;
    using Microsoft.Xrm.Sdk.Query;
    using System.ServiceModel.Description;
    using System.Data.SqlClient;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using Xrm;using System.ServiceModel;

    using System.Security;

    5)Edit the webconfig
    example
    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <section name="microsoft.xrm.client"
          type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client"/>
      </configSections>
      <connectionStrings>
        <add name="Xrm" connectionString="Authentication Type=Passport; Server=https://tcpoc.crm5.dynamics.com; User ID=sales@tcpoc.onmicrosoft.com; Password=Welcome1234; Device ID=11v96fhh51cky1hjcy9p3lqm9s ; Device Password=V~*FsZ/j.1`zRMer?kVLZTXq" />
      </connectionStrings>
      <microsoft.xrm.client>
        <contexts>
          <add name="Xrm" type="Xrm.XrmServiceContext, TestConnect" />
        </contexts>
      </microsoft.xrm.client>
        <system.web>
            <compilation debug="true" targetFramework="4.0" />
          <pages>
          <controls>
            <add tagPrefix="crm" namespace="Microsoft.Xrm.Portal.Web.UI.WebControls" assembly="Microsoft.Xrm.Portal" />
          </controls>
          </pages>
          </system.web>
    </configuration>

    example

    //Authenticate using credentials of the logged in user;




    string UserName = "admin@opcare1.onmicrosoft.com"; //your Windows Live ID


    string Password = "Welcome1"; // your password


    ClientCredentials Credentials = new ClientCredentials();

    Credentials.UserName.UserName = UserName;

    Credentials.UserName.Password = Password;

    Credentials.Windows.ClientCredential =

    CredentialCache.DefaultNetworkCredentials;


    //This URL needs to be updated to match the servername and Organization for the environment.


    Uri OrganizationUri = new Uri("https://opcare1.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"); //this URL could copy from Setting --> Developer Source




    Uri HomeRealmUri = null;


    //OrganizationServiceProxy serviceProxy;


    using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, GetDeviceCredentials()))



    {


    IOrganizationService service = (IOrganizationService)serviceProxy;


    Guid ind_guid = new Guid();


    Entity ind = new Entity("contact");


    string firstname = TextBoxFirstname.Text;


    string lastname = TextBoxLastname.Text;

    ind[
    "firstname"] = firstname.ToUpper();

    ind[
    "lastname"] = lastname.ToUpper();

    ind_guid = service.Create(ind);



    }

               


     



     
     




     

     

    http://msdn.microsoft.com/en-us/library/gg695790.aspx#generate

    Wednesday 29 August 2012

    Introduction

    Hello & Good day,
     
    I am just an ordinary who love to share my finding through my everyday job. I am a principal consultant in Mason Technologies. My work mostly technical and involve of implementation and customisation of crm solution package. I have work with ms dynamic crm 4, ms dynamic 2011 and a little bit of oracle on demand crm. Working in a team, upon stumble with bump and hump of customer requirement, i love to share the solution and idea. Thanks for reading the blog and hopefully it is useful and helpful. :-)