+ Start a Discussion
kalyforminkalyformin 

Dot Net - setting lookup fields value

We are trying to set a lookup value from our C# code. Here is the sample

 

account[0].Agent__r.FirstName = "Willy";

account[0].Agent__r.LastName = "Wonka";

 

The Agent__r is a lookup field in the Account screen which relates to a Contact object. We get an 'Object instance not set to an instance ' error everytime we run the application.

 

Is there a sample on how we can set lookup field values with DotNet?

 

Any help is appreciated.

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

account[0].agent__c = "someId";

where someId is the 18 character salesforce.com Id for the contact record.