You need to sign in to do that
Don't have an account?

Javascript Button doesn't work from Partner Communities
I will be implementing Partner Communities. I am testing in a dev org to confirm functionality. I have a Button on the Contact that executes javascript. It works fine from the internal org but gives this error from the community:
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
The button code is
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")};
var dob = '{!Contact.Birthdate}';
var sal = '{!Contact.Annual_Income__c}';
var plandate = '{!Contact.Date_Entered_Plan__c}';
var inflation = '{!Contact.Expected_Raise_Per_Year__c}';
if( dob == '' || sal == '' ||inflation == '' || plandate == '')
{
alert('Please Validate Birthdate/Annual Income/Date Entered Plan/Expected Raise Per Year/ Spouse DOB');
}
else
{
sforce.apex.execute("GeneratePensionReport","attachReport", {id:"{!Contact.Id}"});
window.alert("Pension Report has been Generated and Attached." );
}
I think this issue has to do with the context - since it is running from the community it thinks it has a different domain. Not sure how to address this.
Any help would be appreciiated.
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
The button code is
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")};
var dob = '{!Contact.Birthdate}';
var sal = '{!Contact.Annual_Income__c}';
var plandate = '{!Contact.Date_Entered_Plan__c}';
var inflation = '{!Contact.Expected_Raise_Per_Year__c}';
if( dob == '' || sal == '' ||inflation == '' || plandate == '')
{
alert('Please Validate Birthdate/Annual Income/Date Entered Plan/Expected Raise Per Year/ Spouse DOB');
}
else
{
sforce.apex.execute("GeneratePensionReport","attachReport", {id:"{!Contact.Id}"});
window.alert("Pension Report has been Generated and Attached." );
}
I think this issue has to do with the context - since it is running from the community it thinks it has a different domain. Not sure how to address this.
Any help would be appreciiated.
Have create GeneratePensionReport global and global,static method attachReport and give access to communit this class. May be this info helps you.
Thanks for respoding
The class is global. I don;t even think it gets that far. I believe it stops at the REQUIRESJAVASCRIPT because it can't resolve the url. I have tried putting in the site reference but I haven't found the right answer.
Here is the class.
global class GeneratePensionReport {
WebService static void attachReport(id ContId) {
PageReference pdf = Page.PensionReportPDF;
pdf.getParameters().put('id',ContId);
pdf.setRedirect(true);
Blob b;
if(!System.Test.isRunningTest())
b = pdf.getContent();
else
b=blob.valueOf('Text for Testing');
Attachment attachment = new Attachment();
attachment.Body = b;
attachment.Name = String.valueOf('PensionReport.pdf');
attachment.ParentId = ContId;
insert attachment;
}
}
I'm having the exact same problem. Could you please tell me what the problem was with the original button? Thank you!
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")};
Those AJAX / . js is not available for a community partner to use. It will work fine with a standard license or an old PRM / Gold partner license, but community licenses do not have access to use them.
Same problem. resolved by updating the correct link of the the partner community.
Incorrect -- developer.salesforce.com/Opp.id
Correct - developer.salesforce.com/partnerportal/Opp.id
What I did:
Check JS in the custom button: find navigareToUrl function in your code...then added partnerportal name..like below..
navigateToUrl("/partnerportal/setup/ui/recordtypeselect.jsp?ent=01Ib00000002MnA&retURL=%2F"+varRetId+ ...