Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
    
Does your code touch anything from in installed package that's not visible to the site profile user? –  Lex Mar 31 at 7:01
    
updated the question. Where i am explaining how the class works. –  AnuRaj Mar 31 at 7:39
    
Maybe on your live server you have additional triggers? Are the same packages installed in the two orgs? –  Lex Mar 31 at 8:33
    
In all the installed env we have this issue. But in the development env we don't have this issue. –  AnuRaj Mar 31 at 8:49
    
Are you sure that the user that executes the code has licenses for the application? Can you show the piece of code that throws the error? –  Lex Mar 31 at 11:49

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.