+ Start a Discussion
micwamicwa 

Picklist: Assign in Apex

Hi

I need to convert a contact back to a lead. The contact object has a picklist "Gender__c" and the leadobject has a picklist "Gender__c" too. When I try to create a new leadobject and asign the gender to it I get an "System.StringException: Invalid id: male" error.

Code:
Contact contact = [Select c.Gender__c from Contact c where c.Id = ... limit 1];
Lead createdLead = new Lead(Gender__c = contact.Gender__c);

 How do I have to assign that?
micwamicwa
Found the problem by myself. The code I posted works...

The Exception was caused by something else.