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
AngiB.ax1285AngiB.ax1285 

Managed Apps - VF Page inputfield rendered problem in Professional Edition (PE) ONLY

Hello all,

 

We have a Managed Application with a page that works off of a custom object we have built.

(Actually we have 2 managed applications that have virtually identical pages - one has been released for about 1 year now and one is pending security review)

BOTH have the identical problem.

 

On these pages depending on the choice the user makes with one field (drop down list) the page will render different lookup fields for them to choose from.

So if I choose 'User' then a User object lookup appears

If I choose 'Account' then an Account object lookup appears

If I choose 'Contact' then a Contact object lookup appears

etc.

 

So we are making use of the 'rendered' attribute on the apex:inputfield on the page to show/hide as required.

 

This works PERFECTLY in our development org as well as many other orgs on which our customers have it installed.

EXCEPT any org that is running PROFESSIONAL EDITION.

 

The VF Page and Controller full code is included in full below.

 

We have read EVERYTHING we can get our hands on about PROFESSIONAL EDITION and we cannot find any reasonable explanation why this code will work for everyone else but not in PE.

 

Any assistance anyone can lend us in unravelling this mystery would be GREATLY appreciated.

Thanks

AngiB

 

---------------------------

VF Page:

 

<apex:page controller="Assign_Equipment" tabStyle="Equipment__c">

<style type="text/javascript">
function DisableLookUp()
{
DisableLookUp();
return false;
}
</style>
  <apex:form id="form">
  <apex:actionFunction action="{!DisableLookUp}" name="DisableLookUp" reRender="form"/>
    <apex:pageBlock >
    <apex:pageBlockSection title="Assign Equipment" columns="1">
    <apex:outputField value="{!obj.Name}"/>
    <apex:outputField value="{!obj.Equipment_Tag__c}"/>
    <!--apex:outputField value="{!obj.Assigned_Type__c}"/>-->
    <apex:outputField value="{!obj.Assigned_Name__c}"/>     
     </apex:pageBlockSection>
     <apex:pageBlockSection title="Assign Equipment" columns="8" id="pageBlock">
     <table id="tab1">
     <tr id="row1">
     <td id="col1">
     <apex:inputField value="{!obj1.Assigned_Date__c}" required="true"/>
     </td>
     </tr>
     <tr id="row2">
     <td id="col1">
     <apex:inputField value="{!obj.Assigned_Type__c}" id="Assign" required="true" onchange="DisableLookUp();"/> 
     <apex:inputField value="{!obj1.Assigned_User__c}" id="User" rendered="{!RenderUser}"/>
     <apex:inputField value="{!obj1.Assigned_Account__c}" id="Acc" rendered="{!RenderAccount}"/>
     <apex:inputField value="{!obj1.Assigned_Contact__c}" id="Cont" rendered="{!RenderContact}"/>
     <apex:inputField value="{!obj1.Assigned_Opportunity__c}" id="Opp" rendered="{!RenderOpportunity}" />
     </td>
     </tr>
     </table>
     </apex:pageBlockSection>
    <apex:pageBlockSection Columns="3">
     <apex:commandButton value="Assign" action="{!Assign}"/>
     <apex:commandButton value="Cancel" action="{!Cancel}"/>
    </apex:pageBlockSection>    

    </apex:pageBlock>  
  </apex:form>
  <script type="Text/javascript">
 var hd_value = {!ActiveChk}; //For Active CheckBox True
 //alert(hd_value);
 var curr_url = document.location.href;
 //alert(curr_url);
 var temp = new Array();
 temp = curr_url.split('=');
 var EQ_id = temp[1];
 //alert(EQ_id);
 var E_ID;
 if(EQ_id.indexOf('&')> -1)
 {
     temp = EQ_id.split('&');
     E_ID = temp[0];
 }
 else
 {
     E_ID = EQ_id;
 }
 //alert(E_ID);
 var temp1 = new Array();
 temp1 = curr_url.split('apex');
 var int_url = temp1[0];
 //alert(int_url);
 var fnl_url = int_url+E_ID;
 //alert(fnl_url);
 if(hd_value == false)
 {
     alert("You cannot Assign Inactive Equipment . Please change the Equipment to Active.");
     window.location = fnl_url;
 }
  </script>
</apex:page>

 

Controller Class:

public with sharing class Assign_Equipment {

    public ELTON__Equipment__c obj {get;set;}
    public ELTON__Equipment__c obj1 {get;set;}
    public ELTON__Equipment_Assignment__c objEAOld {get;set;}
    public string EId;
    public User us{get;set;}
    public ELTON__Equipment__c objEquipment{get;set;}
    public User objUser{get;set;}
    public Account objAcc{get;set;}
    public Contact objCon{get;set;} 
    public Opportunity objOpp{get;set;} 
    List<ELTON__Equipment_Assignment__c> lstEA = new List<ELTON__Equipment_Assignment__c>();       
    List<ELTON__Equipment_Assignment__c> EAsToUpdate = new List<ELTON__Equipment_Assignment__c>();       

    //Variable Declaration
    public boolean RenderUser {get; set;}
    public boolean RenderAccount {get; set;}
    public boolean RenderContact {get; set;}
    public boolean RenderOpportunity {get; set;}
    public string Name{get;set;}
    public string Type{get;set;}
    public boolean ActiveChk {get;set;}

    public Assign_Equipment()
    {
      EId = ApexPages.CurrentPage().getParameters().get('id');
      Init();
    }

    public void Init()
    {
        try
        {
           RenderUser = false;
           RenderAccount = false;
           RenderContact = false;
           RenderOpportunity = false;
           obj1 = new ELTON__Equipment__c();
           obj = [select Id,Name,ELTON__Active__c,ELTON__Equipment_Tag__c,
             ELTON__Assigned_Account__c,ELTON__Assigned_Address__c,ELTON__Assigned_City__c,ELTON__Assigned_Contact__c,
             ELTON__Assigned_Country__c,ELTON__Assigned_Date__c,ELTON__Assigned_Email__c,ELTON__Assigned_Mobile__c,
             ELTON__Assigned_Name__c,ELTON__Assigned_Opportunity__c,ELTON__Assigned_Other_Phone__c,ELTON__Assigned_Phone__c,
             ELTON__Assigned_State_Province__c,ELTON__Assigned_Type__c,ELTON__Assigned_User__c,ELTON__Assigned_Zip_Postal_Code__c   
             from ELTON__Equipment__c where Id=:EId];  
      
           if(obj.ELTON__Assigned_Name__c!=null){Name = obj.ELTON__Assigned_Name__c;}
           if(obj.ELTON__Assigned_Type__c!=null){Type = obj.ELTON__Assigned_Type__c;}
                      
           ActiveChk = obj.ELTON__Active__c;
           if(Test.isRunningTest())  
           {/* Do Nothing */}
           else 
           {obj.ELTON__Assigned_Type__c=null;
           }
        }
        catch(Exception ee)
        {
            
        }
    }
    
    public void DisableLookUp()
    {
        try
        {
            if(obj.ELTON__Assigned_Type__c == 'User')
            {
            RenderUser = true;
            RenderAccount = false;
            RenderContact = false;
            RenderOpportunity = false;
            }
            else if(obj.ELTON__Assigned_Type__c == 'Account')
            {
            RenderAccount = true;
            RenderUser = false;
            RenderContact = false;
            RenderOpportunity = false;
            }
            else if(obj.ELTON__Assigned_Type__c == 'Contact')
            {
            RenderContact = true;
            RenderAccount = false;
            RenderUser = false;
            RenderOpportunity = false;
            }
            else if(obj.ELTON__Assigned_Type__c == 'Opportunity')
            {
            RenderOpportunity = true;
            RenderAccount = false;
            RenderUser = false;
            RenderContact= false;
            }
            else
            {
            RenderAccount =false;
            RenderUser = false;
            RenderContact = false;
            RenderOpportunity = false;
            }
        }
        catch(Exception ee)
        {
            
        }
    }
    
    public PageReference Assign()
    {
    try
      {

      //Testing stuff
      if(Test.isRunningTest())
      {
         obj1.ELTON__Assigned_Type__c = obj.ELTON__Assigned_Type__c;
         obj1.ELTON__Assigned_User__c = obj.ELTON__Assigned_User__c;            
         obj1.ELTON__Assigned_Account__c = obj.ELTON__Assigned_Account__c;
         obj1.ELTON__Assigned_Opportunity__c = obj.ELTON__Assigned_Opportunity__c;
         obj1.ELTON__Assigned_Contact__c = obj.ELTON__Assigned_Contact__c;                                    
         obj1.ELTON__Assigned_Date__c = obj.ELTON__Assigned_Date__c;            
          
      }

      // null out obj fields 
      obj.ELTON__Assigned_Account__c = null;
      obj.ELTON__Assigned_Address__c = '';
      obj.ELTON__Assigned_City__c = '';
      obj.ELTON__Assigned_Contact__c = null;
      obj.ELTON__Assigned_Country__c = '';
      obj.ELTON__Assigned_Email__c = '';
      obj.ELTON__Assigned_Mobile__c = '';
      obj.ELTON__Assigned_Opportunity__c = null;
      obj.ELTON__Assigned_Other_Phone__c = '';
      obj.ELTON__Assigned_Phone__c = '';
      obj.ELTON__Assigned_State_Province__c = '';
      obj.ELTON__Assigned_User__c = null;
      obj.ELTON__Assigned_Zip_Postal_Code__c = '';

      // set fields from page
      obj.ELTON__Assigned_Date__c =obj1.ELTON__Assigned_Date__c;     
      
      if(obj.ELTON__Assigned_Type__c == 'Opportunity')
      {
             if(obj1.ELTON__Assigned_Opportunity__c != null)
             {
              objOpp = [select id,Name from Opportunity 
                                   where Id=:obj1.ELTON__Assigned_Opportunity__c];
             
              if(objOpp.Name!=null)
              {
                  obj.ELTON__Assigned_Name__c=objOpp.Name;
              }

              obj.ELTON__Assigned_Opportunity__c = obj1.ELTON__Assigned_Opportunity__c;
             
               }
      }
      else if(obj.ELTON__Assigned_Type__c == 'User')
      {
     
         if(obj1.ELTON__Assigned_User__c!=null)
         {
          objUser = [select id,Name,MobilePhone,Email,Phone,Street,State,PostalCode,Country,City,Department from User where Id=:obj1.ELTON__Assigned_User__c];

          if(objUser.Street == null){objUser.Street = '';}
          if(objUser.City == null){objUser.City = '';}
          if(objUser.Country == null){objUser.Country = '';}
          if(objUser.Email == null){objUser.Email = '';}
          if(objUser.MobilePhone == null){objUser.MobilePhone = '';}
          if(objUser.Phone == null){objUser.Phone = '';}                    
          if(objUser.State == null){objUser.PostalCode = '';}
          if(objUser.PostalCode == null){objUser.PostalCode = '';}                    
                                                            
          obj.ELTON__Assigned_Address__c = objUser.Street;          
          obj.ELTON__Assigned_City__c = objUser.City;
          obj.ELTON__Assigned_Country__c = objUser.Country;
          obj.ELTON__Assigned_Email__c=objUser.Email;
          obj.ELTON__Assigned_Mobile__c =objUser.MobilePhone;
          obj.ELTON__Assigned_Name__c=objUser.Name;
          obj.ELTON__Assigned_Other_Phone__c='';
          obj.ELTON__Assigned_Phone__c =objUser.Phone;
          obj.ELTON__Assigned_State_Province__c = objUser.State;
          obj.ELTON__Assigned_Zip_Postal_Code__c = objUser.PostalCode;
          
          obj.ELTON__Assigned_User__c = obj1.Elton__Assigned_User__c;
          
         }
     }
     else if(obj.ELTON__Assigned_Type__c == 'Account')
     {
         if(obj1.ELTON__Assigned_Account__c!=null)
         {
          objAcc = [select id,Name,Phone,BillingCity,BillingCountry ,BillingPostalCode,BillingState,BillingStreet from Account where Id=:obj1.ELTON__Assigned_Account__c];

          if(objAcc.BillingStreet == null){objAcc.BillingStreet = '';}
          if(objAcc.BillingCity == null){objAcc.BillingCity = '';}          
          if(objAcc.BillingCountry == null){objAcc.BillingCountry = '';}    
          if(objAcc.Phone == null){objAcc.Phone = '';}      
          if(objAcc.BillingState == null){objAcc.BillingState = '';}          
          if(objAcc.BillingPostalCode == null){objAcc.BillingPostalCode = '';}          
          
          obj.ELTON__Assigned_Address__c = objAcc.BillingStreet;          
          obj.ELTON__Assigned_City__c = objAcc.BillingCity;
          obj.ELTON__Assigned_Country__c = +' '+objAcc.BillingCountry;
          obj.ELTON__Assigned_Email__c='';
          obj.ELTON__Assigned_Mobile__c = '';
          obj.ELTON__Assigned_Name__c = objAcc.Name;
          obj.ELTON__Assigned_Other_Phone__c='';
          obj.ELTON__Assigned_Phone__c =objAcc.Phone;
          obj.ELTON__Assigned_State_Province__c = objAcc.BillingState;
          obj.ELTON__Assigned_Zip_Postal_Code__c = +' '+objAcc.BillingPostalCode;
          
          obj.ELTON__Assigned_Account__c = obj1.ELTON__Assigned_Account__c;
         }
     }
     else if(obj.ELTON__Assigned_Type__c == 'Contact')
     {
         if(obj1.ELTON__Assigned_Contact__c!=null)
         {
          objCon= [select id,Name,Phone,Email,OtherPhone,MobilePhone,Department,MailingCity,MailingCountry,MailingPostalCode,MailingState,MailingStreet from Contact where Id=:obj1.ELTON__Assigned_Contact__c];

          if(objCon.MailingStreet == null){objCon.MailingStreet = '';}
          if(objCon.MailingCity == null){objCon.MailingCity = '';}
          if(objCon.MailingCountry == null){objCon.MailingCountry = '';}
          if(objCon.Email == null){objCon.Email = '';}
          if(objCon.MobilePhone == null){objCon.MobilePhone = '';}
          if(objCon.OtherPhone == null){objCon.OtherPhone = '';}
          if(objCon.Phone == null){objCon.Phone = '';}
          if(objCon.MailingState == null){objCon.MailingState = '';}
          if(objCon.MailingPostalCode == null){objCon.MailingPostalCode = '';}          
                                                            
          obj.ELTON__Assigned_Address__c = objCon.MailingStreet;
          obj.ELTON__Assigned_City__c = objCon.MailingCity;
          obj.ELTON__Assigned_Country__c = objCon.MailingCountry;
          obj.ELTON__Assigned_Email__c = objCon.Email;
          obj.ELTON__Assigned_Mobile__c =objCon.MobilePhone;
          obj.ELTON__Assigned_Name__c=objCon.Name;
          obj.ELTON__Assigned_Other_Phone__c =objCon.OtherPhone;
          obj.ELTON__Assigned_Phone__c=objCon.Phone;
          obj.ELTON__Assigned_State_Province__c = objCon.MailingState;
          obj.ELTON__Assigned_Zip_Postal_Code__c = objCon.MailingPostalCode;

          obj.ELTON__Assigned_Contact__c = obj1.ELTON__Assigned_Contact__c;
          
         }
    }

    // If the Assigned_Type was left null then basically do no updates
    // Not the most elegant of solutions but easy enough to explain
    if(obj.ELTON__Assigned_Type__c != null)
    {
       // Update the Equipment Object
       update obj;

       // Update previous Equipment Assignment Record - Any without a return date get the Assigned_Date as returned Date
       List<ELTON__Equipment_Assignment__c> lstEA = 
          [select Id,ELTON__Account__c,ELTON__Address__c,ELTON__City__c,ELTON__Contact__c,
          ELTON__Country__c,ELTON__Assigned_Date__c,ELTON__Email__c,ELTON__Mobile__c,
          ELTON__Name__c,ELTON__Opportunity__c,ELTON__Other_Phone__c,ELTON__Phone__c,
          ELTON__State_Province__c,ELTON__Assigned_Type__c,ELTON__User__c,ELTON__Zip_Postal_Code__c,
          ELTON__Return_Date__c 
          from ELTON__Equipment_Assignment__c where ELTON__Equipment__c=:EId and ELTON__Return_Date__c=null]; 
    
      if (lstEA.size() > 0)
      {             
      for(ELTON__Equipment_Assignment__c objEAOld: lstEA)
         {                
         objEAOld.ELTON__Return_Date__c=obj.Assigned_Date__c;
         EAsToUpdate.add(objEAOld);             
         }             
      update EAsToUpdate;            
      }

      // Create Equipment Assignment Record for new Assignment
      ELTON__Equipment_Assignment__c objEA = new ELTON__Equipment_Assignment__c ();
      objEA.ELTON__Account__c=obj.ELTON__Assigned_Account__c;
      objEA.ELTON__Address__c=obj.ELTON__Assigned_Address__c;
      objEA.ELTON__Assigned_Date__c=obj.ELTON__Assigned_Date__c;
      objEA.ELTON__Assigned_Type__c = obj.ELTON__Assigned_Type__c;
      objEA.ELTON__City__c=obj.ELTON__Assigned_City__c;
      objEA.ELTON__Contact__c=obj.ELTON__Assigned_Contact__c;
      objEA.ELTON__Country__c=obj.ELTON__Assigned_Country__c;
      objEA.ELTON__Email__c=obj.ELTON__Assigned_Email__c;
      objEA.ELTON__Equipment__c = EId;
      objEA.ELTON__Mobile__c=obj.ELTON__Assigned_Mobile__c;
      objEA.ELTON__Name__c=obj.ELTON__Assigned_Name__c;
      objEA.ELTON__Opportunity__c = obj.ELTON__Assigned_Opportunity__c;
      objEA.ELTON__Other_Phone__c=obj.ELTON__Assigned_Other_Phone__c;
      objEA.ELTON__Phone__c=obj.ELTON__Assigned_Phone__c;
      objEA.ELTON__Return_Date__c=null;
      objEA.ELTON__State_Province__c=obj.ELTON__Assigned_State_Province__c;
      objEA.ELTON__User__c=obj.ELTON__Assigned_User__c;
      objEA.ELTON__Zip_Postal_Code__c=obj.ELTON__Assigned_Zip_Postal_Code__c;

      insert objEA ; 
    } 
   } 
 catch(Exception ee)
 {
 
 }
PageReference page1= new ApexPages.Standardcontroller(obj).view();
                page1.setRedirect(true);
                return page1;
   
}

    public PageReference Cancel(){
         
         PageReference Page= new PageReference('/'+EId);
                Page.setRedirect(true);
                return Page;
    }