I have created a VF page and using class as extensions of the VF page. I have created a site in the VF page as home page. The page is getting displayed but when i click the submit button on the VF page i am getting an error
The installed managed class is not visible
I my class i have object called candidate from site i am entering the records into candidate and with the candidate i am also attaching the resume to the record. The profile for site have access to the candidate object. The issue seems to be with the saving of the record as the VF page loads and this error throws up only when we save the record. Two things happen there one candidate record is created and attachment is created and added to this candidate record. Interestingly this work fine on the environment where we are developing but is failing when installed in a different environment.
My code: Apex Class
public ctrl_Candidate_Site(ApexPages.StandardController stdController){
ca_Insert = new Candidates__c();
ca_Insert = (Candidates__c)stdController.getRecord(); // getting records from VF page
jobID = ApexPages.currentPage().getParameters().get('jobId'); // Getting the jobId from URL
a = new Attachment();
}
public PageReference SaveResult(){
ca_Insert.Name = ca_Insert.First_Name__c + ' ' +ca_Insert.Last_Name__c;
if(jobID != null ){
ca_Insert.Position__c = jobID;
}
Savepoint sp = Database.setSavepoint();
Database.SaveResult sr = Database.insert(ca_Insert , false);
//insert ca_Insert;
if(sr.isSuccess() ){
system.debug('Attachment value and inside is Success ' + Attach);
if(Attach != null){
a.Body=Attach;
a.Name=filename;
a.ParentID=sr.id;
// a.ParentId = ca_Insert.id;
system.debug('Inside Is Success before attachmant get added ' + a );
try {
if(a != null){
insert a;
isSaved = true;
}
}
catch(System.DMLException e) {
Database.rollback(sp);
ca_Insert.clear();
system.debug('If attachmant save have issues ' + e);
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Not able to attach your Resume. Resume format should be doc, docx, txt, pdf.');
ApexPages.addMessage(myMsg);
}
}
else{
Database.rollback(sp);
ca_Insert.clear();
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Please add your resume.');
ApexPages.addMessage(myMsg);
}
}
else{
for(Database.Error err : sr.getErrors()) {
System.debug('The following error has occurred.');
System.debug('the error ' + err.getStatusCode() + ': ' + err.getMessage());
System.debug('Account fields that affected this error: ' + err.getFields());
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'No record get inserted. Please Try again.');
ApexPages.addMessage(myMsg);
}
}
if(isSaved == true){
PageReference pr = page.Thank;
//pr.setRedirect(true);
system.debug('page url ' + pr);
return pr;
}
else
return null;
}
VF page:
<apex:composition template="{!$Site.Template}" >
<apex:define name="body" >
<apex:form id="Cnd_form" >
<h1>Candidate</h1>
<table class="tableStyle">
<apex:repeat value="{!$ObjectType.Candidates__c.FieldSets.Candidate}" var="f">
<tr>
<td class="tdStyleFirst">
<apex:outputText value="{!f.Label}" />
<apex:outputText value="*" style="color:red;" rendered="{!OR(f.DBRequired, f.required)}" /></td>
<td><apex:inputField value="{!Candidates__c[f]}" required="{!OR(f.DBRequired, f.required)}" /> </td>
</tr>
</apex:repeat>
<tr>
<td>Attach Resumes</td>
<td><apex:inputFile value="{!Attach}" accept="doc, docx, txt, pdf" filesize="1000" filename="{!fileName}"></apex:inputFile> </td>
</tr>
<tr>
<td></td>
<td> <apex:commandButton action="{!SaveResult}" value="Submit"/>
<apex:commandButton action="{!cancel}" value="Reset"/> </td>
</tr>
</table>
</apex:form>
</apex:define>
The first time when the page get displayed their is not problem found. But when i click on the submit button or reset button the error displays.
I have defined the class as sharing, the VF page is accessed by the site profile user. All the object and the fields used in the class are been accessed by the profile. The version of the VF page and the class are same. But even then i am getting error that The installed managed class is not visible. Do anybody have any idea what is the issue? Please guide me to get it solved.
Attribution to: AnuRaj
Possible Suggestion/Solution #1
Is the VisualForce page part of the package as well? I suspect it isn't which is why you're seeing this problem. You can't use any code from a managed package in an unmanaged page or class unless it's defined as having global
scope.
Attribution to: Matt Lacey
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31369