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
eric_wceric_wc 

Custom case creation page

I am trying to create a custom case creation page but I am stuck on how to get the contact and account lookup fields values on the VF page saved with the case.  Here is my vf and apex code:

 

 

<apex:page controller="newcaseController" tabStyle="Case">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  
  <script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
      return false;
  }
  </script>
  <apex:sectionHeader title="new case"/>
      <apex:form >
          <apex:pageBlock title="Case info" mode="edit">
          <apex:pageBlockButtons >
              <apex:commandButton action="{!save}" value="Save"/>
              <apex:commandButton action="{!cancel}" value="Cancel"
                                          onclick="return confirmCancel()" immediate="true"/>
          </apex:pageBlockButtons>
          <apex:pageblocksection title="Contact and Account info info">
              <apex:inputField id="contactName" value="{!case.contactid}"/>
              <apex:inputField id="accountName" value="{!case.accountid}"/>
              <apex:inputField id="rootcause" value="{!case.root_cause__c}"/>
              
              
              
          </apex:pageblocksection>
          </apex:pageblock>
      </apex:form>
         
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

 

 

public class newcaseController {

Case case1;


public Case getCase() {
    if(case1 == null) case1 = new Case();
    return case1;
    
}

    


public PageReference step1() {
    return Page.casestep1;
}

public PageReference cancel() {
    PageReference casePage = new ApexPages.StandardController(case1).view();
    casePage.setRedirect(true);
    return casePage;
}

public PageReference save() {
    case1.subject = 'popup blocker issue';
    
    insert case1;
    
    PageReference casePage = new ApexPages.StandardController(case1).view();
    casePage.setRedirect(true);
    
    return casePage;
}
}

 I am very new to this and have been going through the VF and Apex developers guides but cannot figure his out.

 

Thanks

Eric

 

 

Ispita_NavatarIspita_Navatar

Please try the following:-

 

<apex:inputField id="contactName" value="{!case.contact.name}"/>
<apex:inputField id="accountName" value="{!case.account.name}"/>

 

Did this answer your question? If not, let me know what didn't  work, or if so, please mark it solved.

eric_wceric_wc

I have tried that but is does not use the contact and account search field...

Thanks though

Eric