Using OrganizationServiceClient in CRM 2011


 Add Service Reference to the Organization WCF service in the application.

URL àhttp://servername:port/OrganizationName/xrmServices/2011/organization.svc 

Use the following code to perform various functions using OrganizationServiceClient 


Entity myContact = new Entity();

myContact.LogicalName = “contact”; 

AttributeCollection myAttColl = new AttributeCollection();

myAttColl.Add(new KeyValuePair<string, object>(“lastname”, “Rana”));

myContact.Attributes = myAttColl;
ClientCredentials credentials = new ClientCredentials();

Uri organizationUri = new Uri(http://servername:port/organizationname/xrmServices/2011/organization.svc&#8221;);

try
{
OrganizationServiceClient orgClient = new OrganizationServiceClient();
 

orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(“username”, “password”, “domain”); 

orgClient.Create(myContact);

}
catch (Exception ex)
{

throw ex;

} 

Hope it helps.

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

12 thoughts on “Using OrganizationServiceClient in CRM 2011”

  1. Hi Nishant,

    Hope you are doing well.
    I am trying to retrieve data from “CRM 2011” using “Organization” webservice.
    Whenever I am trying to connect this webservice it gives “Server not found error Error”.

    So my question is whether “CRM 2011” supported by “Windows Phone 7” or not?

    Please help 😦
    Thanks
    Surojit

    Like

  2. Hi, nice article.
    However, when we try to add an address to an account, that we made up your way, it tells us we need to specify the ‘parentid’. We’ve done this, but then it throws an exception that the parentid cannot be NULL. Whilst debugging it doesn’t show that its null.

    Can you help us out?

    Barry

    Like

  3. This code connects to CRM But I dont know how to close the incidents after Could someone help me?
    Thanks
    string crmServerUrl = “http://myserver/mygroup/”;
    string connectionStringIntegrated = string.Format(“Url={0};”, crmServerUrl);
    string connectionString = connectionStringIntegrated;

    var connection = CrmConnection.Parse(connectionString);

    using (var service = new OrganizationService(connection))
    {

    using (var crm = new CrmOrganizationServiceContext(service))
    {
    //Resolve Incidents and Cancel Incidents in here by passing in the incidentID

    }
    }

    Like

  4. I found this will Close Incidents, However I still can not programatically close the associated activities.

    Entity caseResolution = new Entity(“incidentresolution”);
    caseResolution.Attributes.Add(“incidentid”, new EntityReference(“incident”, new Guid(“MYGUIDHERE”)));
    caseResolution.Attributes.Add(“subject”, “testing programatic closing.”);

    //service.Create(caseResolution);

    Microsoft.Crm.Sdk.Messages.CloseIncidentRequest req = new Microsoft.Crm.Sdk.Messages.CloseIncidentRequest();
    req.IncidentResolution = caseResolution;
    req.RequestName = “CloseIncident”;
    OptionSetValue o = new OptionSetValue();
    o.Value = 5;
    req.Status = o;

    Microsoft.Crm.Sdk.Messages.CloseIncidentResponse resp = (Microsoft.Crm.Sdk.Messages.CloseIncidentResponse)service.Execute(req);

    Like

  5. Everywhere, of course, with the exception of the
    Hellenestic Greek States. This will probably come naturally, especially if you dominate the Ultralisk instead of letting it rampage on its own, since it gets
    a rack of kills on its destruction run. With the amount of possibilities the demo
    suggests, it would seem this is THE game to keep your peepers open for.

    Like

  6. We have simply completed making War of Mercenaries Hack Device.
    This is more about tabletop-game design theory with slight social discussion. Evil Genius is a very entertaining, if flawed, video game.

    Like

Please share your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM