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
AvaniAvani 

API access and Javascript.

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.

 

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

 

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


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");
var ans=records[0].Submitted_as_Proposal__c;
var opps = new Array();
opps[0] = new sforce.SObject("Opportunity");
opps[0].id = "{!Opportunity.Id}";
opps[0].Submitted_as_Proposal__c = 'Y' ;
if(ans=='N')
{
var prop = new sforce.SObject("Proposal__c");
var rfq=new Date("{!Opportunity.RFQ_Date__c}");
rfq.setDate(rfq.getDate());
var rfp=new Date("{!Opportunity.RFP_Date__c}");
rfp.setDate(rfp.getDate());
var rfi=new Date("{!Opportunity.RFI_Date__c}");
rfi.setDate(rfi.getDate());
var adt=new Date("{!Opportunity.Estimated_Award_Date__c}");
adt.setDate(adt.getDate());
var pdt=new Date("{!Opportunity.Estimated_Proposal_Due_Date__c}");
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");

}

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

 

 

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf

Well, you could do a simple call like sforce.connection.getUserInfo();.  If that fails, then you have no API access.  If it succeeds, then you have access.

 

Also, if you're making an AppExchange package, you can specify that your package requires the API -- then it won't even install in the first place to orgs that have no API access.

All Answers

werewolfwerewolf

You probably wanted to post this to the AJAX board, but that's OK.

 

Professional Edition does not have access to the API (unless they buy the API addon).  In your Javascript, you are using the API.  Therefore what you have done here simply won't work in PE (without the API addon).

AvaniAvani
Werewolf, thanks much for replying back.

Is there a way to write a Javascript without using API... Also, is there any suggestion that you may have to have a workaround to bypass the need of API add on for PE edition.

Avani.

ps I shall post this thread to Ajax board as per your suggestion.
werewolfwerewolf
Not really.  You pretty much need the API to do what you're doing there.
AvaniAvani
werewolf, thanks much again.

How about .net pages, you will get the api (xml file) from saleforce site. Include that with .net page and then convert the code wrote in javascript to vb.

This project (web application) would consist of one or two .aspx pages and api(xml file) which would take in user credentials of user and then code logic converted to .net.

DO YOU THINK THIS WILL WORK.
werewolfwerewolf
That would still be using the API, so no, that will not work.
amorganamorgan
How can I detect if API access is available or not?
werewolfwerewolf

Well, you could do a simple call like sforce.connection.getUserInfo();.  If that fails, then you have no API access.  If it succeeds, then you have access.

 

Also, if you're making an AppExchange package, you can specify that your package requires the API -- then it won't even install in the first place to orgs that have no API access.

This was selected as the best answer