4

We have a bunch of custom fields on a lead which are required to be copied to the contact when a conversion takes place. We want to clear these fields after the conversion, as they contain sensitive information which we do not want to be able to query. But the lead is read only. How can I prevent converted leads from being queried since I cannot update or delete them (see docs).

Thanks

3

It is not possible to create a trigger on the Contact that queries back to the Lead via Lead.ConvertedContactId and clears the required fields as once the Lead has been converted there is no way to update any fields. It becomes read-only. See Ideas: Converted Leads - Ability to Edit Values (Admins Only) the lead hasn't been updated yet (see lead conversion trigger order)


Does clearing the field(s) in a before update trigger on the Lead work. You could check the Lead.IsConverted field. When it is true the Lead is being converted and the fields should be cleared before it is locked down as read-only. I'm not sure at what point the resulting Contact gets the field values copied over.

In the same Lead before update trigger you could check for the ConvertedContactId field being populated and update the corresponding values in the Contact before the ones on the Lead are cleared.

It is worth reading the answer to Lead Conversion Trigger Order of Execution. The Lead Before Update and Lead After Update triggers will fire after the Contact has been created.

The Lead after update trigger will probably be too late to perform further DML on the lead.

  • Thanks Daniel, I ended up following your advice and copied the fields to the contact on a before update trigger on the lead, then cleared out the lead fields. – Jim May 7 '13 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.