You need to sign in to do that
Don't have an account?
Ajax Tookit error "Sforce not defined" in customer community
I have a custom list button called New Form, Here is the code
=========================================
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/28.0/apex.js")}
var url = top.window.location.href;
var profile = '{!$Profile.Name}';
var IsAuthorized = false;
if(profile.indexOf("Admin") != -1 || profile.indexOf("FAE/FTS") != -1 || profile.indexOf("Portal") != -1){
IsAuthorized = true;
}
if(!IsAuthorized){
alert("Not right to create BX-041 form.");
}else{
var deviceId = url.substr(url.indexOf('.com/')+5,15);
var queryString = "SELECT id FROM BX_041__c where Device__c = '" + deviceId + "'";
var queryResult = sforce.connection.query(queryString);
if(queryResult.size > 0 ) {
alert("You can't Create another BX-041 record.");
}else {
window.open("{!URLFOR($Action.BX_041__c.New, null,null,false)}","_parent");
}
}
=================================================================
It is working for internal users, but when customer portal user click this button in customer community, it says "sforce not defined". Even not working for system admin. So i doubt ajax toolkit is not supported in community.
Anyone has any idea?
Regards,
Thomas
Hello,
Is this issue happening in IE7 or Chrome browser? If yes, then refer following help document for solution:
https://help.salesforce.com/apex/HTViewSolution?urlname=Receiving-error-sforce-apex-is-null-or-not-an-object-1327108329858&language=en_US
Hi Vinita,
Thanks for the reponse, but I am using FF.
Add one thing, this issue happened only on UAT sandbox, it is working fine on other sandboxes.
Regards,
Thomas
Hello Thomas,
In this case it doesn't seem to be browser specific. If this is happening in just one Org then i would request you to cross verify your code from the Org where it is working.