• Doug Weyers
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

As per release winter 16 release notes: http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/salesforce_release_notes.htm

REQUIRESCRIPT no longer executes JavaScript on Page Load.

We use the REQUIRESCRIPT function in several custom buttons on our lead page.  When the Winter 16 features were released into our sandbox, our buttons started returning an error Reference $ Undefined.

I reached out to salesforce support, and they told me to use the code in the following article which removed the REQUIRESCRIPT function and instead, creates a custom java function.


I've been messing with the code above to fit it into my button.  I'm stepping through the code through alerts, it stepped all the way through but at the end I get an Object error.  Any help would be appreciated.

function loadScript(url) 

    var request; 
    if (window.XMLHttpRequest) 
        request = new XMLHttpRequest(); 
    else if (window.ActiveXObject) 
        request = new ActiveXObject("Msxml2.XMLHTTP"); 
        if (!request) 
            request = new ActiveXObject("Microsoft.XMLHTTP"); 

    var se = document.createElement('script'); 
    se.type = "text/javascript"; 
    //alert("before Request undefined\n");
    request.open("GET", url, false); 
    se.text = request.responseText; 
    //alert("end of loadScript\n");



    var j$ = jQuery.noConflict(); 
    var newurl= sforce.apex.execute("RegisterMerchant", "getPricingArticleID",{leadID : "{!Lead.Id}"}); 
    newurl1 = String(newurl); 
    alert('Lead ArticleID '+newurl1); 
    if(newurl1.indexOf('error')>-1 ) 



    alert('Start of Else Statement')
    var strQuery="Select l.of_Pin_Pads__c,l.Id, l.Article_ID__c, l.Processing_Origin__c, l.Company, l.Strategic__c, l.Gift_Only__c, l.Dealer__r.Name, l.Developer__c, l.DLR_Sales__c, l.Name, l.OwnerId from Lead l where Id= '" +'{!Lead.Id}'+"'"; 
    var accFields = sforce.connection.query(strQuery); 
    var records = accFields.getArray("records"); 

    var owner = records[0].OwnerId; 
    var ContactName = records[0].Name; 

    var leadId = records[0].ID; 
    var Dealer = records[0].Dealer__r.Name; 
    var devID = records[0].Developer__c; 
    var Developer = null; 
    var DealerSalesperson = null; 
    if (devID!=null) 
    alert('Developer Record')

    var strQuery3 = "SELECT Name from Account where ID='" +devID+"'"; 
    var devField = sforce.connection.query(strQuery3); 
    var devRecord = devField.getArray("records"); 
    Developer = devRecord[0].Name; 

var ds = records[0].DLR_Sales__c; 
//if (ds!= null) 
    alert('DLR sales Record1')
var strQuery6 = "Select Name from Contact where id = '" +ds+"'"; 
var dlrSalesField = sforce.connection.query(strQuery6); 
var dlrSalesRecord = dlrSalesField.getArray("records"); 
DealerSalesperson = dlrSalesRecord[0].Name; 
alert('Dlr sales Record2') 

var NumberOfPinpads = 0; 
NumberOfPinpads = parseInt(records[0].of_Pin_Pads__c); 
alert('Pin Pads') 
var ArticleId = records[0].Article_ID__c; 
var ProcessingOrigin = records[0].Processing_Origin__c; 
var CompanyName = records[0].Company; 
var StrategicAccount= records[0].Strategic__c; 
var GiftOnly = records[0].Gift_Only__c; 
alert('Other stuff') 

// if diff is null, continue, if user clicked cancel, allow them to chg processing origin 
console.log('leadId '+leadId+'--'+Dealer+'--'+Developer+'--'+ArticleId+'--'+DealerSalesperson); 
// next section stolen from Josh, thanks for doing my typing buddy! 
var $articleId = $('<input>', { name: 'ArticleId', type: 'hidden', value: ArticleId }); 
var $processingOrigin = $('<input>', { name: 'ProcessingOrigin', type: 'hidden', value: ProcessingOrigin }); 
var $companyName = $('<input>', { name: 'CompanyName', type: 'hidden', value: CompanyName }); 
var $strategicAccount = $('<input>', { name: 'StrategicAccount', type: 'hidden', value: StrategicAccount }); 
var $giftOnly = $('<input>', { name: 'GiftOnly', type: 'hidden', value: GiftOnly }); 
var $contactName = $('<input>', { name: 'ContactName', type: 'hidden', value: ContactName }); 
var $dealer = $('<input>', { name: 'Dealer', type: 'hidden', value: Dealer }); 
var $developer = $('<input>', { name: 'Developer', type: 'hidden', value: Developer }); 
var $dealerSalesperson = $('<input>', { name: 'DealerSalesperson', type: 'hidden', value: DealerSalesperson }); 
var $numberOfPinpads = $('<input>', { name: 'NumberOfPinpads', type: 'hidden', value: NumberOfPinpads }); 

var $form = $('<form>', { 
'action': '{!$Label.pricingUI}Invoke', 
'method': 'post', 



// alert('done by me');