Unmatch Company/Person from a Lead

Is it possible to add a button/link to the Lead screen which will "unmatch" a Company or Person from the Lead?

It is possible to do by editing the record, saving it with a new Comapny, clicking the "Add or Find this Company link" and selecting the new Company in the usual manner but this seems a lot of user involvement to simply clear a match.

  • 0

    Here is one way you can do it....

    1. Create a new .asp file with the following code:


    <%

    var IndId = "Key44";

    var strRecordId = new String(Request.QueryString(IndId));

    var sqlStr = "UPDATE Lead SET Lead_PrimaryCompanyId = NULL WHERE Lead_LeadId = "+strRecordId;

    CRM.ExecSql(sqlStr);

    Response.redirect(CRM.url("192"));

    %>


    For this example, this will be saved in the location of:

    WWWRoot\CustomPages\ClearLead


    With the name:

    ClearLeadComp.asp


    2. Create a new button group against the lead.

    Navigate to:

    Administration - Advanced Customisation - Button Groups

    Configure as below:

    • Caption: Unlink Company
    • Action: customfile
    • Custom File: ClearLead\ClearLeadComp.asp
    • SQL: lead_primarycompanyId IS NOT NULL
    • Bitmap: Whatever you like...

    Add that to the button group, then save.

    The button will then be added to the company summary:


    Then when pressed, it will navigate round to the lead screen having run the UPDATE statement in the .asp file to NULL the lead_primarycompanyId

    You may want to make it nicer by adding a confirmation page. You can either bundle the person into the same action, or do the same with another button & .asp file to give the option to unlink the person.

    Hope that helps.

  • 0

    Toby this is great - I had to tweak a couple of typos (the "object" in ASP and ensuring the Button link matched the ASP page name) but otherwise this is exactly what I was after. Thanks a lot!

  • 0

    Sorry, that was left over from a comment that was omitted, my bad. Edited the post to correct the errors, also the .asp had some stuff in it it didn't need, so streamlined it a little.