Thursday, November 8, 2007

Another Null Reference Exception CRM

Task post create event:

public override void PostCreate(...)
{
Guid opportunityId = task.regardingobjectid.Value;
this.opportunity = (opportunity)service.Retrieve(EntityName.opportunity.ToString(), opportunityId, new AllColumns());

opportunity.new_textfield = "hello world"; // throws a NullReferenceException

string newtext = "hello world";
opportunity.new_textfield = newtext; // works fine
}

No comments: