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
anuraj123anuraj123 

Class is not visible in managed package.

HI,
I have created a VF page and extensions for VF page a extension. I am using custom object as standardController and create a filed set in the object which i am using in the VF page. On this VF page after entering the values in the fields they can upload file and hit save. This portion is done by the extensions. And add the page as the home page of the site after installing to a env (Managed package). But hit save after entering the values and uploading the file it throws an error - Class is not visible. This same happens if it is accessed by the administrator. So i converted the package as unmanaged and installed it again in the same env. Here this time it works. I have made the same setting for the managed and unmanged package but for managed it dose't works. The fields , object and VF page is visible to the 'User License Guest'. But when i click on edit for 'Enabled Apex Class Access' the class is not found for managed package.

My class and VF page code:

class:
public with sharing class ctrl_Candidate_Site{


public Candidates__c ca_Insert {get; set;} // For inserting Candidates records
public blob Attach {get;set;}  // For attaching Resume to the specific record
public String fileName {get; set;}
public Attachment a {get; set;}
public Id jobID {get; set;}// To get the ID from URL
public Boolean isSaved{get; set;}// To know is saved successfully

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 page.Candidate_Site;
    }
  }



}

VF page:
<apex:page id="Cnd_page1" showHeader="false" title="{!$Label.site.site_login}" standardController="Candidates__c" extensions="ctrl_Candidate_Site">

<apex:pageMessages ></apex:pageMessages>

<style>
    h1{
        font-size:16px;
        padding-left:50px;
        font-family:'trebuchet ms', helvetica, sans-serif;
        color:#3366FF;
        line-height:20px;
    }
    .tableStyle{
        padding-left:50px;
        font-size:14px;
        font-family:'trebuchet ms', helvetica, sans-serif;
        color:#343434;
    }
    .cm_formCss{
         height:100%;
         margin:auto;
         width:960px;


    }
    .tdStyleFirst{
        height:25px;
        margin-bottom:13px;
        margin-left:2px;
        width:50%;
    }
    .tdStyleSecond{
        height:25px;

    }

  </style>
  <script>

    function onComplete() {

        var url = '/apex/Thank';
        window.open(url);
    }
  </script>


  <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>

I am not able to understand why this dose't work with managed but works with unmanaged. Even admin cannot access the class for managed package. Please guide me to get the solution for this issue.
Thanks
Anu
Ashish_SFDCAshish_SFDC
Hi Anu, 


Need some more information on  this, 

Are you bulding the App as Partner ? 

It is the Salesforce Security for the Managed Package's App that Code is not visible for the Managed Packages and it is Working as Designed. 

Where as an Un Managed package code is visible to the Org where it is Installed which can be edited / called or modified. 


Regards,
Ashish