title: CRM 2011: How to Update record in a Create Plugin?
body: <p>I'm having serious problems in how to update the record that has just been created with some additional data. </p>
  
  <p>Case: I have an sms activity. On create an sms record. A plugin fires to actualy send the sms. A third party sms provider takes cares of the sending and returns a status string. Based on these string, a status for the sms must be updated.</p>
  
  <p>Here's some of my code:</p>
  
  <pre class="lang-csharp prettyprint-override"><code>public void Execute(IServiceProvider serviceProvider)
  {
    IPluginExecutionContext context = (IPluginExecutionContext)
    serviceProvider.GetService(typeof(IPluginExecutionContext));
  
    IOrganizationServiceFactory serviceFactory = 
      (IOrganizationServiceFactory)serviceProvider.GetService(
        typeof(IOrganizationServiceFactory));
    IOrganizationService service = 
      serviceFactory.CreateOrganizationService(context.UserId);
    aContext orgContext = new aContext(service);
  
    Entity sms = (Entity)context.InputParameters["Target"];
    /// logic goes here
  
    sms.StatusCode = new OptionSetValue(statuscode); //statuscode is integer
    service.Update(sms);
  }
  </code></pre>
  
  <p>I got a error in the plugin everytime i execute the plugin. Can someone help and explain me what i'm doing wrong here? </p>
  
  <p>Thanks!</p>