Use the OrganizationService to Create a new Account

  1. Using the CRMServices class from the previous post, add a new Web Form.  Give it a name like Test.aspx
  2. Add a Literal control with an ID like, AccountGuideLiteral
    <form id=”form1″ runat=”server”>
    <div>
    <asp:Literal ID=”AccountGuidLiteral” runat=”server”></asp:Literal>
    </div>
    </form>
  3. In the code view should look like this:
    using CRMServices;
    using Microsoft.Xrm.Sdk;
    using System;namespace Test
    {
    public partial class Test : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    var service = OrgService.GetOrgService();Entity account = new Entity(“account”);
    account[“name”] = “Test Account2”;
    account[“address1_line1”] = “123 Main St.”;

    Guid accountid = service.Create(account);

    AccountGuidLiteral.Text = accountid.ToString();
    }
    }
    }

Leave a comment