0

When in Sandbox and the image is clicked there is a redirect to addApprenticeDetailsAccountLookup and is shown in the section on the opportunity page layout, however when the image is clicked in production the addApprenticeDetails page appears as a full page in the tab.

Controller

public class addApprenticeDetails_CX {

    public String fName { get;set; }
    public String lName { get;set; }
    public String email { get;set; }
    public String accName { get;set; }
    public Id AccId { get;set;}
    public List<Account> accList { get;set;} 
    Public Opportunity currentRecordId { get; set; }

    public addApprenticeDetails_CX(ApexPages.StandardController controller){
       currentRecordId = (Opportunity)controller.getRecord();
    }

    public PageReference callLookup(){
        accList = [Select id,Name from Account];
        PageReference pr = new PageReference('/apex/addApprenticeDetailsAccountLookup');
        pr.setRedirect(false);
        return pr;
    }

    public PageReference goBack(){
        accName = ApexPages.currentPage().getParameters().get('AccName');
        AccId = ApexPages.currentPage().getParameters().get('AccId');
        PageReference pr = new PageReference('/apex/addApprenticeDetails');
        pr.setRedirect(false);
        return pr;
    }

    public PageReference save(){
        if(lName == null || lName == ''){
            ApexPages.addmessage(new 
       ApexPages.message(ApexPages.severity.WARNING,
       'Last Name is Required!'));
            return null;
        }
        if(email == null || email == ''){
            ApexPages.addmessage(new 
        ApexPages.message(ApexPages.severity.WARNING,
        'Email is Required!'));
            return null;    
        }
        else{
            Contact con = new Contact();

            con.FirstName = fName;
            con.LastName = lName;
            con.Email = email;
            con.AccountId = AccId;
            con.RecordTypeId = 
    Schema.SObjectType.Contact.getRecordTypeInfosByName().
    get('Corporate Contact').getRecordTypeId();
            con.Third_Party_Opportunity__c =  
    ApexPages.currentPage().getParameters().get('Id');
            insert con;


            PageReference pr = new PageReference('/apex/addApprenticeDetails');
            pr.setRedirect(true);
            return pr;

        }
    }
    public list<Account> accs { get; set; }
    public String searchString { get; set; }
    public addApprenticeDetails_CX(){

    }
    public void search(){
        string searchQuery = 'select name, id from account where name like 
    \'%'+searchString+'%\'Limit 20';
        accs = Database.query(searchQuery);

    }
    public void remove(){
        accs.clear();
    }
}

addApprenticeDetails VF Page

<apex:page standardController="Opportunity" 
extensions="addApprenticeDetails_CX">
    <apex:form >
        <apex:actionFunction name="callAction" action="{!callLookup}"/>
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:pageMessages />
                <apex:inputText label="First Name" value="{!fName}"/>
                <apex:inputText label="Last Name" value="{!lName}"/>
                <apex:inputText label="Email" value="{!email}"/>
                <apex:inputText label="Lookup Account" style="float:left;" value="{!accName}">
                    <apex:image 
value="https://api.icons8.com/download/
19343120d27c16dd3e9d21ad3aa637f94fd4d5fa/Android_L/PNG/256/
Very_Basic/search-256.png" height="20" onclick="callAction()"/>
                </apex:inputText>
            </apex:pageBlockSection>
            <center>
                <apex:commandButton value="Save" action="{!save}"/>
            </center>
        </apex:pageBlock>
    </apex:form>
</apex:page>

addApprenticeDetailsAccountLookup VF page

<apex:page standardController="Opportunity" 
extensions="addApprenticeDetails_CX" tabStyle="Contact">
    <apex:form >
        <apex:inputText value="{!searchString}" label="Input"/>
        <apex:commandButton value="Search Accounts" action="{!search}"/>
        <apex:commandButton value="Clear Accounts" action="{!remove}"/>
        <apex:pageBlock title="Search Results">
            <apex:pageBlockSection columns="1">
                <apex:repeat value="{!accs}" var="acc">
                    <apex:commandLink value="{!acc.Name}" action="{!goBack}">
                        <apex:param value="{!acc.Name}" name="AccName"/>
<apex:param value="{!acc.Id}" name="AccId"/>
                    </apex:commandLink>
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
  • 1
    Is this used as a visualforce "card" inside a Record Detail Page? If so, the setup for the detail page may be different in production than in your sandbox. – crmprogdev Mar 22 '18 at 12:29
  • This is in a section on the opportunity page layout. I have checked the configuration of both prod and sandbox and they match. The section is never directed to addApprenticeDetailsAccountlookup page. – Hannah Mar 22 '18 at 16:41
  • This might be an issue of permissions. Check to see that your production users have permission to access the visualforce pages and controllers. – crmprogdev Mar 22 '18 at 22:32
  • I have only made it available for System Admins and they do have access to both the pages and the controller. – Hannah Mar 26 '18 at 11:15
0

The issue with this code is line accList = [Select id,Name from Account]; I have added a limit Too many query rows.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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