crm.hideButton for converting a Lead to an Opportunity or Communication

This question is not answered

Hi all,

Sage CRM 7.2 SP1

We currently have some Custom Content in place for the Lead screen, which will hide the 'Convert to Opportunity' button if a Lead has been converted to a Communication:

<script>
crm.ready(function()
{
 if (crm.fields('lead_communicationid').value() != "")
  crm.hideButton('newopportunity.gif');
}
)
</script>

This works without a problem. However, it doesn't work if we try and hide the 'Convert to Communication' button, if a Lead has already been converted to a Communication:

<script>
crm.ready(function()
{
 if (crm.fields('lead_oppono').value() != "")
  crm.hideButton('NewTask.gif');
})
</script>

I find this very strange, since it's the same crm.ready(function() script. Any ideas?

If I run the script above using Developer Tools in Internet Explorer 11, it hides the button successfully. As soon as I put it into the Custom Content box, it doesn't work.

Thanks

Hannah

All Replies
  • Hannah - Are these custom buttons that have been added to the Lead summary screen?

    In your 2nd script (the one that doesn't work) is "lead_oppono" a custom field or should you be looking at "lead_opportunityid" instead?

    If I understand correctly, these two scripts are in the CustomContent of the same screen - if so, you could combine them into one script:

    <script>

    crm.ready(function()

    {

    if (crm.fields('lead_communicationid').value() != "")

     crm.hideButton('newopportunity.gif');

    if (crm.fields('lead_oppono').value() != "")

     crm.hideButton('NewTask.gif');

    }

    )

    </script>

    Paul Cowper
    Marda Associates Ltd

    S-Link: Sage 50 Integration for Sage CRM.

    FormPop: Launch any Sage 200 forms from any Sage CRM page.

    Contract programming, development and implementation - Sage 50 (UK version), 200, 300 and CRM.  Prompt, confidential service.

  • Hi Hannah,

    I would check to see what mode the screen is in first before checking the value of the field and hiding the button.

    Try this if Paul's suggestion isn't working for you.

    <script>

    crm.ready(function()

    {

    var strMode = crm.fields("lead_description").getMode();

    if(strMode=="view") {

    //crm.infoMessage(strMode);

    if (crm.fields('lead_oppono').value() != "")

     crm.hideButton('NewTask.gif');

    }

    });

    </script>

  • Thanks both,

    We managed to get this working by fiddling around with the order of our scripts in the Custom Content.

    Thanks