client side api not available when linking lead to company

Hey guys,

I'm using some of the client side api functionality in my Company New Entry screen (both Custom Content and OnChange Scripts). Everything is working fine when creating/editing a company, but when I go to a Lead record and try to create a new company from the lead using the Add or Find this Company link (Act=1860) none of the client side functionality seems to work.

crm.fields('comp_name').value() gives me undefined

crm.fields('comp_name').collapse() does nothing

Also the crm.ready function in custom content fires before the company values are set from the lead fields.

Anyone else experiencing this or can test it to see if you if you can replicate the issue? Thanks :-)

This is in CRM 7.3a

  • 0

    Brad

    I tried

    Add of Find this company (Action 1860)

    Add or Find this Person (Act=1202)

    These both load the Clientside API

    These are pages which list companies and people who match the criteria and would not display unless a match is found.

    If the company/person is ignored then the resulting company entry screen (Act=140) does link to the client side API.

    General commands do work e.g.

    crm.infoMessage("hello")

    but some fail e.g.

    var myfield = crm.fields("comp_name")

    myfield.value()

    myfield.caption()

    This indicates that the stucture of the page is sufficiently different to prevent fields being identified using the clientside API.

    The fields are however identified using HTML tag IDs

    e.g.

    input type="text" class="EDIT" id="comp_name" name="comp_name" value="" maxlength="60" size="35">

    The work around would be to use the standard HTML document.getElementById("id") e.g. document.getElementById("comp_name").

    You will need to report a case to customer services.

  • 0

    After doing some additional testing here is what I've found. In the Z010_crmAPICore.js file under wwwroot\js\crm there is a function which instantiates the fields object (see below). The problem is the Lead to Company screen doesn't match any of the criteria in the function to get the list of inputs. "PopupWin" is not an argument in the url. So as a work around on the lead company detail screen I added this code.

    crm.ready(function()

    {

    $("a[class=SmallButtonItem]").attr("onclick",function(i,v)

    {

    return v.replace('fromwebpicker=true','fromwebpicker=true&PopupWin=y')

    });

    })

    This code adds the "PopupWin=y" to the url string of the "Add or Find this Company/Person" hyperlinks so that it instantiates the crm.fields object. It works as a temporary fix but obviously needs fixed in the code. I hope this helps anyone else who is trying to use the client side api on the lead to company popup window :-)

    function getAllFieldNames()

    {

    var fieldNames=[],inputs,i,len,name,lastName;

    if(getAllFieldNames.cached)

    {

    return getAllFieldNames.cached;

    }

    if(window.name==="EWARE_MID_IFRAME_ASP")

    {

    inputs=$("input[entrytype]");

    }

    else

    {

    if(crm.getArg("PopupWin").toLowerCase()==="y")

    {

    inputs=$("input[entrytype]");

    }

    else

    {

    inputs=$("input[entrytype]","#EWARE_MID");

    }

    }

    for(i=0,len=inputs.length;i

    {

    name=inputs[i].name.replace(rHiddenPrefix,"");

    if(lastName!==name)

    {

    fieldNames.push(name);

    }

    lastName=name;

    }

    if(documentReady)

    {

    getAllFieldNames.cached=fieldNames;

    }

    return fieldNames;

    }