function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.