+ Start a Discussion
AvaniAvani 

Javascript and API Access.

Gurus,

need a big help. Got to deploy the code tomorrow morning and it does not work.



I wrote a javascript to create a custom button called Submit Proposal on Opportunity page. It is an onclick Javascipt.



The code is working fine on Developer edition but when I deploy it as a package in Professional edition, it is throwing me an error saying " API access" is disabled. I tried uploading the code as a package on appexchage to bypass the API thingy, still it does not work.

I understand that in PE edition without the API add-on this javascript does not work. Is there a workaround to bypass the need of API add on as the customers does not have monies given the dire-difficult economic situation.



Here is the code, if you happen to have any suggestion for struggling me..



OnClick JavaScript {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js":smileywink:}


var oppid="{!Opportunity.Id}";
var sql1 = "Select Submitted_as_Proposal__c from Opportunity Where Id = '" + oppid + "'" ;
var result = sforce.connection.query(sql1);
var records= result.getArray("records":smileywink:;
var ans=records[0].Submitted_as_Proposal__c;
var opps = new Array();
opps[0] = new sforce.SObject("Opportunity":smileywink:;
opps[0].id = "{!Opportunity.Id}";
opps[0].Submitted_as_Proposal__c = 'Y' ;
if(ans=='N')
{
var prop = new sforce.SObject("Proposal__c":smileywink:;
var rfq=new Date("{!Opportunity.RFQ_Date__c}":smileywink:;
rfq.setDate(rfq.getDate());
var rfp=new Date("{!Opportunity.RFP_Date__c}":smileywink:;
rfp.setDate(rfp.getDate());
var rfi=new Date("{!Opportunity.RFI_Date__c}":smileywink:;
rfi.setDate(rfi.getDate());
var adt=new Date("{!Opportunity.Estimated_Award_Date__c}":smileywink:;
adt.setDate(adt.getDate());
var pdt=new Date("{!Opportunity.Estimated_Proposal_Due_Date__c}":smileywink:;
pdt.setDate(pdt.getDate());
prop.name = "{!Opportunity.Name}";
prop.CRGT_Role__c="{!Opportunity.CRGT_Role__c}";
prop.Prime_Name__c="{!Opportunity.Prime_Name__c}";
prop.Sub_Name__c="{!Opportunity.Sub_Name__c}";
prop.Total_Contract_Vlaue__c="{!Opportunity.Total_Contract_Value__c}";
prop.CRGT_Value__c="{!Opportunity.CRGT_Value__c}";
prop.Lead_Source__c="{!Opportunity.Lead_Source__c}";
prop.OwnerId="{!Opportunity.OwnerId}";
prop.Account__c="{!Opportunity.AccountId}";
prop.Contract_Vehicle__c="{!Opportunity.Contract_Vehicle__c}";

if(rfq!='NaN')
{
prop.RFQ_Date__c=rfq;
}
if(rfi!='NaN')
{
prop.RFI_Estimated_Date__c=rfi;
}
if(rfp!='NaN')
{
prop.RFP_Date__c=rfp;
}
if(adt!='NaN')
{
prop.Estimated_Award_Date__c=adt;
}
if(pdt!='NaN')
{
prop.Estimated_Proposal_Due_Date__c=pdt;
}
if(rfp!='NaN')
{
prop.RFP_Date__c=rfp;
}
sforce.connection.create([prop]);
sforce.connection.update(opps);
alert("This Opportunity is now submitted as a proposal":smileywink:;

}

else
{
alert("This Opportunity has already been submitted as a proposal":smileywink:;
}