When a Lead is qualified it will always create a new Opportunity record and will also create a new Account and Contact record as well unless you identify the Lead as belonging to an existing Account and/or existing Contact. In our use case, which I don't think is unique, we track both the Account and Contact associated with an Opportunity. In our use case we set a specific Account for new Leads and set the customerid field on the Lead form using Javascript.
When we qualify the Lead a new Opportunity is created and the customerid field is inherited from the Lead and a reference to the Lead is populated in the originatingleadid field. A new Contact is also created with information from the Lead and a reference to the same Lead is populated in the originatingleadid field.
Now, I would like to populate the newly created Opportunity with a reference to the newly created Contact in a custom field say new_contactid. The only way I can get to the newly created contactid (Contact) is from the originatingleadid field.
Can I get the contactid value from a Contact record querying on the originatingleadid field using Javascript or some other method?
Any help appreciated. Thanks!