function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DustinLHDustinLH 

Java Button - Works in IE/Firefox but not Chrome

I have a custom button that executes OnClick Javascript and it works fine in IE and in Firefox, but in Chrome I get the following error message:

 

A problem with the OnClick JavaScript for this button or link was encountered:

 

{faultcode:'soapenv.Client', faultstring:'Missing entity type information. sObject requires a separate 'type' field be sent.',}

 

It is odd to me because I do not really understand the message and it works in the other two browsers, so it shouldn't be a mapping problem. The code takes a custom object (called referral) and maps fields from that to a new Lead that it creates. It also updates the referral status and ties the Lead to it. The code is below. Can anyone help me figure out the issue? Thanks!

 

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}
    {!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}

    if ("{!Referral__c.Status__c}" == "Converted")
    {
        alert("Referral {!Referral__c.Name} has already been converted to a Lead. To view the Lead, please see the Related Lead field on the Referral.");
    } else
    {
        var Lead = new sforce.SObject("Lead");
        Lead.Referrer_Branch__c = "{!JSENCODE(Referral__c.Branch_Referred_By__c)}";
        Lead.Business_or_Individual__c = "{!Referral__c.Business_Individual__c}";
        Lead.Client_Type__c = "Prospect";
        Lead.Company = "{!JSENCODE(Referral__c.Company_Name__c)}";
        Lead.Referrer_Department__c = "{!JSENCODE(Referral__c.Department_Referred_By__c)}";
        Lead.Email = "{!JSENCODE(Referral__c.Referral_Email__c)}";
        Lead.FirstName = "{!JSENCODE(Referral__c.Referral_First_Name__c)}";
        Lead.LastName = "{!JSENCODE(Referral__c.Referral_Last_Name__c)}";
        Lead.LeadSource = "Referral";
        Lead.Status = "Open - Not Contacted";
        Lead.Phone = "{!JSENCODE(Referral__c.Phone__c)}";
        Lead.RecordTypeId = "01280000000EtDm";
        Lead.Referral_Address__c = "{!JSENCODE(Referral__c.Referral_Address__c)}";
        Lead.Referral_Comments__c = "{!JSENCODE(Referral__c.Comments__c)}";
        Lead.Referral_Company__c = "{!JSENCODE(Referral__c.Company_Name__c)}";
        Lead.Referral_Contact_Method__c = "{!Referral__c.Contact_Method__c}";
        Lead.Referral_Creator__c = "{!JSENCODE(Referral__c.Record_Creator__c)}";
        Lead.Referral_Email__c = "{!JSENCODE(Referral__c.Referral_Email__c)}";
        Lead.Referral_First_Name__c = "{!JSENCODE(Referral__c.Referral_First_Name__c)}";
        Lead.Referral_ID__c = "{!JSENCODE(Referral__c.Id)}";
        Lead.Referral_Last_Name__c = "{!JSENCODE(Referral__c.Referral_Last_Name__c)}";
        Lead.Referral_Phone__c = "{!JSENCODE(Referral__c.Phone__c)}";
        Lead.Referral_Preferred_Time__c = "{!Referral__c.Preferred_Time__c}";
        Lead.Referral_Product__c = "{!Referral__c.Product__c}";
        Lead.Referral_Record_Type__c = "{!Referral__c.RecordType}";
        Lead.Secondary_Name__c = "{!JSENCODE(Referral__c.Secondary_Name__c)}";
        Lead.Secondary_Relationship__c = "{!Referral__c.Secondary_Relationship__c}";
        Lead.What_brought_Referral_into_the_bank__c = "{!JSENCODE(Referral__c.What_brought_Referral_into_the_bank__c)}";

        var refResult = sforce.connection.create([Lead]);

        if (refResult[0].getBoolean("success")) {
            // now update the referral to reflect that it was successfully updated
            var currentReferral = new sforce.SObject("Referral__c");
            currentReferral.Id = "{!Referral__c.Id}";
            currentReferral.Status__c = "Converted";
            currentReferral.Related_Lead__c = refResult[0].id;
            var result = sforce.connection.update([currentReferral]);
            
            // redirect to newly created lead
            var redirectLocation = refResult[0].id;
            window.location = redirectLocation;
    } else {
        alert("Failed to convert Referral. " + refResult[0]);
    }
}

 

BilbaoBilbao

We actually have the same problems but it occurs seldomly. Basically when the button is clicked on a few records it gives the error, otherwise it goes fine. After going nuts we have recommended our users to use Firefox. 

Does anyone have a solution for this?

Thanks