+ Start a Discussion
kstites1kstites1 

Broken S-Control

This s-control doesn't work and I can't figure out why.  You can click on the custom link and it just takes you to a white screen and then does nothing.  The opportunity doesn't get updated either.

 

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Executed Contract Received</title>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script>
function initPage() {
//Initialize the connection to salesforce.com by setting the sessionid and the
//soap endpoint in the init call
sforceClient.setLoginUrl("https://www.salesforce.com/services/Soap/u/7.0");
sforceClient.registerInitCallback(startUp);
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", false);
}

function startUp() {

var Type="{!Opportunity.Type}";
var Status="{!Opportunity.Export_Status__c}";
var Profile="{!$User.ProfileId}";
//if(Profile = "00e30000000g5na"){
// var retUrl = "https://na1.salesforce.com/" + "{!Opportunity.Id}";
// window.parent.parent.location.href = retUrl;
// alert("You do not have the proper permissions to mark this opportunity as received!");


if ((Type == "Merchants@ Platinum") || (Type == "Merchants@ Gold") || (Type == "Merchants@ Upgrade")) {
if (Status == "Exported"){
var retUrl = "https://na1.salesforce.com/" + "{!Opportunity.Id}";
window.parent.parent.location.href = retUrl;
alert("This opportunity has already been exported!");
}
else{

//set as Ready for export
var myObj = new Sforce.Dynabean("Opportunity");
myObj.set("id", "{!Opportunity.Id}");
myObj.set("Export_Status__c", "Ready");
var saveResults = sforceClient.Update([myObj]);
var retUrl = "https://na1.salesforce.com/{!Opportunity.Id}";
window.parent.parent.location.href = retUrl;
}
}
else if ((Type == "Amendment") || (Type == "Platinum Renewal") || (Type=="Gold Renewal")) {
if ("{!Opportunity.Master_Opportunity__c}" == "") {
var retUrl = "https://na1.salesforce.com/" + "{!Opportunity.Id}";
window.parent.parent.location.href = retUrl;
alert("This opportunity is missing the Master Opportunity field! Please refer to Sales Ops.");
}
else {
//create remedy ticket
var holdback = "%0D%0AReturn Holdback: {!Opportunity.ReturnHoldback__c}%0D%0A";

//get rev shares from contract
var qr = sforceClient.Query("Select Category__c, Product_Rev_Share__c, Gift_Wrap_Rev_Share__c, Shipping_Rev_Share__c from Revenue_Share__c Where Contract__c = '{!Opportunity.Contract_ID__c}' ");
alert(qr);
var fees = "Category+++++++++ Product | Shipping | Giftwrap%0D%0A-----------------------------------------------------------------------%0D%0A";
for (var i=0;i<qr.records.length;i++) {
var revshare = qr.records[i];
var category = revshare.get("Category__c");
var product = revshare.get("Product_Rev_Share__c");
var shipping = revshare.get("Shipping_Rev_Share__c");
var giftwrap = revshare.get("Gift_Wrap_Rev_Share__c");
var fees = fees + category + "++++++" + product + " | " + shipping + " | " + giftwrap + "%0D%0A";
}

//get contract info
var qr = sforceClient.Query("Select Effective_Date__c, SpecialTerms,Description from Contract Where ID = '{!Opportunity.Contract_ID__c}' ");
alert (qr);
for (var i=0;i<qr.records.length;i++) {
var contract = qr.records[i];
var effective = "Effective Date: " +contract.get("Effective_Date__c") + "%0D%0A";
var terms = "Special Terms: " + contract.get("SpecialTerms") + "%0D%0A";
var descr = "Description:" + contract.get("Description") + "%0D%0A";
var descrclean = descr.replace("&", "and");
}

//find all affected storefronts
var masteropp = "{!Opportunity.Master_Opportunity__c}";
var qr = sforceClient.Query("Select Production_Customer_ID__c, Name from Opportunity Where ID = '{!Opportunity.Master_Opportunity__c}'");
alert(qr);
var storefronts = "%0D%0A%0D%0AAffected Storefronts:%0D%0A%0D%0AProd Cust ID +++++ Opportunity Name%0D%0A-------------------------------------------------------------------------------------------------%0D%0A";
for (var i=0;i<qr.records.length;i++) {
var storefront = qr.records[i];
var prodid = storefront.get("Production_Customer_ID__c");
var name = storefront.get("Name");
var storefronts = storefronts + prodid + "+++++" + name + "%0D%0A";
}

//document.write(qr);
// document.write("%0D%0AEffective Date - " + effective+ "%0D%0A%0D%0ASpecial Terms - " + terms + "%0D%0A");
// document.write(storefronts);

//get original opp
//get names and prod ids from all related opps %0D%0A


//document.write("This is where we would create a remedy ticket");

if (Type=="Tax Amendment"){
var retUrl = "https://tt.amazon.com/new?impact=4&category=Website&type=IWS3&item=Tax+Enablement&assigned_group=IWS-Tax-Manual&assigned_individual=tax-engine-bz&problem_location=&case_type=Trouble+Ticket&short_description={!Opportunity.Type}+Request+for%3A+{!Opportunity.Account}&details={!Opportunity.Type}+Request+for%3A+{!Opportunity.Account}&240000007=" + fees + holdback + effective + terms +descrclean + storefronts;&cc_list=&vendor_id=&quantity=&purchase_order_id=&asin=&isd=&upc=&title=&binding=&stock_number=&ship_origin=&invoice_number=&physical_location=&tracking_number=&picture_file_imdex_location=&bol_number=;
}
else
{
var retUrl = "https://tt.amazon.com/new?impact=4&category=Partners&type=Merchant+Engagement&item=Fee+Changes&assigned_group=Merchant+Engagement&assigned_individual=lmirth&problem_location=&case_type=Trouble+Ticket&short_description={!Opportunity.Type}+Request+for%3A+{!Opportunity.Account}&details={!Opportunity.Type}+Request+for%3A+{!Opportunity.Account}&240000007=" + fees + holdback + effective + terms +descrclean + storefronts;&cc_list=&vendor_id=&quantity=&purchase_order_id=&asin=&isd=&upc=&title=&binding=&stock_number=&ship_origin=&invoice_number=&physical_location=&tracking_number=&picture_file_imdex_location=&bol_number=;
}
var myObj = new Sforce.Dynabean("Opportunity");
myObj.set("id", "{!Opportunity.Id}");
myObj.set("Export_Status__c", "Remedy");
var saveResults = sforceClient.Update([myObj]);

window.location.href = retUrl;
}
}


else {
//warn that type is not correct
var retUrl = "https://na1.salesforce.com/" + "{!Opportunity.Id}";
window.parent.parent.location.href = retUrl;
alert("This opportunity has an unrecognized Type!");
}

}

</script>
</head>
<body onload="initPage()">
</body>
</html>

shillyershillyer

It's using the beta version of the AJAX Toolkit, try upgrading to the latest version.

 

Beta Value: https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js

 

Change to this value for version 16.0: /soap/ajax/16.0/connection.js  

 

Hope that helps,

Sati

 

kstites1kstites1
It is still not working for me.  It is like it doesn't even run.
SOSO

I am having the same issue with s control. When I click on the custom link, it just goes to a blank new page and done nothing. Here's my code. Please advise.

 

<html>
<head>

<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script>

var recordCache;
function initPage() {
alert("YO!!!");
    sforceClient.registerInitCallback(setup);
    sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
    setup();
}
function setup() {
    var uInfo = sforceClient.GetUserInfo();
var positionId = "{!Position__c.Id}";
    var queryResult = sforceClient.query("Select Candidate__c From Job_Application__c Where Position__c = '" + positionId + "'"),layoutResults);
}
function layoutResults(queryResult) {
    if (queryResult.className == "Fault") {
        alert("There was an error: " + queryResult.toString());
    }else{
        if(queryResult.size > 0){
alert("OOyshee")
            }
            //var textNode = document.createTextNode(output);
            //document.getElementById("output").innerHTML = output;
        } else {
            alert("No records matched.");
        }
    }
}
function updateStatus(num,newStatus){
    var dynaBean = recordCache[num];
    dynaBean.set("Status",newStatus);
    saveResult = dynaBean.save();
    for(var i=-;i<saveResult.length;i++){
        if (saveResult[i].success == true) {
            alert("RECORD SAVED: " + saveResult[i].Id);
        }else{
            alert("ERROR SAVING RECORD: " + saveResult[i].errors[0].message);
        }
    }
}

</script>
</head>
<body onload="initPage()">
<div id="output"></div>
</body>
</html>

 

 

Thanks,

-SO

 

 

alexannnicalexannnic

Hello, Same happens to our organisation also! We had a number of S-Controls developed a long time ago, which used the beta3.3 ajax api call:

<script src="http://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

 

I think the problem is that since yesterday the beta api was taken down for some reason! Try accessing the URL http://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js

 

and you will see that this page does not exist! 

This is creates a big problem for us as we were not prepared for this sudden change, and all of our scripts are not usable now.

 

Could you please assist? (URGENT!)

Kind Regards,

Alex