1

enter image description hereAs I am new with SalesForce, I have implemented a VF page on that page I am doing lots of stuff like load of data in second object on the slection of first one , Creation of pick list, load of Pageblock on certain condition like that. After all this I am able to save the records as my requirment. Now I want to edit that object, in which I saved this record, I know that we can do by the SalesForce Standard page but I want to edit by my VF page.

So how to do that means Just suppose the object which I want to edit is Acessioning, If I give the ID of particular accesioning in url by query string or click on edit button which we have on standard salesforce list view than my VF page should be open with all the loade fields of that object. and I would be able to update the records.

Please suggest any article or anything which can help me to do this.

MY VF page code is this

      <apex:pageBlockSection >
            <apex:selectList required="true" multiselect="false" size="1" label="Labs" value="{!LabSelectedvalue }"  style="align:left">
            <apex:selectOptions value="{!LabOption}"/>
      </apex:selectList>
       <apex:selectList required="true" multiselect="false" size="1" label="Clients"  style="align:left" value="{!ClientselectedValue}" >
                  <apex:selectOption itemvalue="" itemLabel="--None--" />
                  <apex:selectOptions value="{!Clientoption}"/>
                  <apex:actionSupport event="onchange" action="{!GetPhysicianNameByClient}"  reRender="detailsPhysician"/>
             </apex:selectList> 
        </apex:pageBlockSection>
        <apex:pageBlockSection id="detailsPhysician" >
              <apex:selectList multiselect="false" size="1" label="Facility"  style="align:left" value="{!Facilityselectedvalue}">
                 <apex:selectOption itemvalue="" itemLabel="--None--" />
                 <apex:selectOptions value="{!FacilityOption}" />
             </apex:selectList>
             <apex:selectList multiselect="false" size="1" label="Physician"  style="align:left" value="{!Physicianselectedvalue}">
                 <apex:selectOption itemvalue="" itemLabel="--None--" />
                 <apex:selectOptions value="{!PhysicianOption}" />
             </apex:selectList> 
        </apex:pageBlockSection>

         <apex:pageBlockSection >
             <apex:inputField value="{!objAccession.RequisitionNo__c}"/>
         </apex:pageBlockSection>
         <div style= "width: 40%; float: left;">
          <table cellspacing="20px" align="center">
          <tr>
         <td>
             <label style="color:#4A4A56"> Search Patient </label>
         </td>
         <td>
          <apex:inputtext value="{!SearchPatient}" id="txtSearchPatient" /> </td>
             <td>
             <apex:commandButton value="Search"   reRender="thePanel" onclick="abcd('{!$Component.txtSearchPatient}')" /></td>
             </tr>
             </table>
             </div>
         <div style= "float: right; width: 40%;">
         <apex:outputPanel id="thePanel">
          <apex:pageBlockSection id="pageBlockProcessed" rendered="{!Rendered}">
              <apex:dataTable id="dtPatientRecords"  value="{!objPatientList}" var="pt"  cellspacing="16%" >

               <apex:column headerValue="FirstName">
               <apex:commandLink action="{!PopulateFields}" value="{!pt.FirstName__c}"  >
               <apex:param name="PatientID" assignTo="{!PatientID}" value="{!pt.id}"/>
                <apex:param name="testFirstName" assignTo="{!objPatient.FirstName__c}" value="{!pt.FirstName__c}" /> 
               <apex:param name="testMiddleName" assignTo="{!objPatient.MiddleName__c}" value="{!pt.MiddleName__c}"/>
               <apex:param name="testLastName" assignTo="{!objPatient.LastName__c}" value="{!pt.LastName__c}"/>
               <apex:param name="testAddress" assignTo="{!objPatient.Address__c}" value="{!pt.Address__c}"/>
               <apex:param name="testCountry" assignTo="{!objPatient.Country__c}" value="{!pt.Country__c}"/>
               <apex:param name="testState" assignTo="{!objPatient.State__c}" value="{!pt.State__c}"/>
               <apex:param name="testCity" assignTo="{!objPatient.City__c}" value="{!pt.City__c}"/>
               <apex:param name="testGender" assignTo="{!objPatient.Gender__c}" value="{!pt.Gender__c}"/>
               </apex:commandLink>
               </apex:column>
               <apex:column headerValue="Middle Name" >
               <apex:outputField value="{!pt.MiddleName__c}" />
               </apex:column>
               <apex:column headerValue="Last Name" >
               <apex:outputField value="{!pt.LastName__c}" />
               </apex:column>
              </apex:dataTable>  
         </apex:pageBlockSection>
         </apex:outputPanel>
         </div>
         <div style = "clear:both;"></div>
            <apex:pageBlockSection title="Patient">
                <apex:inputField value="{!objPatient.FirstName__c}" />
              <apex:inputField value="{!objPatient.MiddleName__c}" />
              <apex:inputField value="{!objPatient.LastName__c}" />
             <apex:inputField value="{!objPatient.Address__c}"/>
             <apex:inputField value="{!objPatient.Country__c}"/>
             <apex:inputField value="{!objPatient.State__c}"/>
             <apex:inputField value="{!objPatient.City__c}"/>
             <apex:inputField value="{!objPatient.Gender__c}"/>
             <apex:inputField value="{!objPatient.DOB__c}"/>
             <apex:inputHidden value="{!PatientID}"/>
            </apex:pageBlockSection>
         <apex:pageBlockSection title="Case Information" >
            <apex:selectList required="true" multiselect="false" size="1" label="Case(s)"  value="{!selectedValue}"  >
   <apex:actionSupport event="onchange" action="{!GenerateCaseNumber}" reRender="detail"/>
   <apex:selectOptions value="{!CaseTypeOption }"/>
   </apex:selectList>
   <div>
         <apex:outputPanel id="detail"  >
         <apex:outputLabel value="{!TestFinalCaseNumber}"></apex:outputLabel>
       &nbsp;&nbsp;&nbsp;
          <apex:commandButton Value="Add Specimen"   reRender="detail1"  rendered="{!IF(TestFinalCaseNumber !=null  &&  TestFinalCaseNumber!='',true,false)}">
         </Apex:commandButton>
         </apex:outputPanel>
   </div>
         <!--<apex:commandButton Value="Add Specimen"  action="{!AddSpecimen}" reRender="detail1" >
         </Apex:commandButton>-->
         <apex:outputPanel id="detail1">
        <apex:pageBlockSection id="pageBlockProcessed" rendered="{!RenderedSpecimen}">
        <!-- <apex:dataTable id="calldataTable" value="{!objSpecimen}" var="spec" cellspacing="16%">
         <apex:column headerValue="Tissue Type">
         <apex:selectList multiselect="false" size="1" >
          <apex:selectOptions value="{!TissueTypeOption }"/>
           </apex:selectList>
           </apex:Column>
           <apex:column headerValue="Description">
           <apex:outputLabel value="{!spec.Description__c}"></apex:outputLabel>
           </apex:Column>
         </apex:dataTable> -->
          <style type="text/css">
          .dateFormat{float:left; display:inline-block; clear:both}
          th{white-space: normal;}
          </style>

          <table cellspacing="0">
          <tr>
             <th style="text-align:center"> Tissue Type </th>
           <th style="text-align:center"> Specimen Site</th>
           <th style="text-align:center"> Transport Container/ Medium</th>
          <th style="text-align:center">  Pieces Received </th>
          <th style="text-align:center">  Specimen Description/ Procedure </th>
          <th style="text-align:Center">  Collection Date</th>
          <th style="text-align:center">  Recieved Date</th>
          <th style="text-align:center">  Request Date</th>
          <th style="text-align:center">  Test </th>
           </tr>
           <tr>
            <td>
             <table>
             <tbody>            
          <apex:selectList multiselect="false" size="1" value="{!SelectedTissueType}"  >
          <apex:selectOptions value="{!TissueTypeOption }"/>
           </apex:selectList>
           </tbody>
          </table>

</td>           
<td>
             <table> 
             <tbody> 
          <apex:selectList multiselect="false" size="1"  value="{!SelectedSpecimenSite}" >
          <apex:selectOptions value="{!SpecimenSiteOption }"/>
           </apex:selectList>
           </tbody>
           </table>

</td>  
 <td>
             <table>
             <tbody>            
          <apex:selectList multiselect="false" size="1" value="{!SelectedTransportType}"  >
          <apex:selectOptions value="{!TransportTypeOption }"/>
           </apex:selectList>
           </tbody>
          </table>

</td>         
<td>
        <table>
        <tbody>
        <apex:inputText id="txtPiecesRecieved" value="{!SpecimenPiecesRecieved}" />
        </tbody>
        </table>
</td>           
  <td>
        <table>
        <tbody>
        <apex:inputTextarea id="txtSpecimenDescription" value="{!SpecimenDescription}" />

        </tbody>
        </table>
</td>
<td>
        <table>
        <tbody>
        <apex:pageBlockSectionItem >
        <apex:inputField value="{!objSpecimen.CollectedDate__c}"/>
        </apex:pageBlockSectionItem>

        </tbody>
        </table>
       </td> 
          <td>
        <table>
        <tbody>
          <apex:pageBlockSectionItem >
        <apex:inputField value="{!objSpecimen.ReceivedDate__c}"/>
        </apex:pageBlockSectionItem>
        </tbody>
        </table>
       </td>
       <td>
        <table>
        <tbody>
          <apex:pageBlockSectionItem >
        <apex:inputField value="{!objSpecimen.RequestDate__c}"/>
        </apex:pageBlockSectionItem>
        </tbody>
        </table>
       </td>
             <td>
             <table>
             <tbody>            
          <apex:selectList multiselect="false" size="1" value="{!seletedTestValue}"  >
          <apex:selectOptions value="{!LoadTests }"/>
           </apex:selectList>
           </tbody>
          </table>

          </td> 
           </tr>
          </table>

           </apex:pageBlockSection>
         </apex:outputPanel>
         </apex:pageBlockSection>


        <apex:pageBlockSection title="Comments" >
               <apex:inputField value="{!objComment.Comment__c}" style="width:75%"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
              <apex:commandButton action="{!save}" value="Done"/>
        </apex:pageBlockButtons>
    </apex:pageblock>
</apex:form>


<script type="text/javascript">
   function abcd(id)
     {
       var temp=document.getElementById(id).value;
       if(temp==null||temp=='')
       {
         alert("Please enter any of the Patient Information");
         return false;
        }
        else
        {
            validatedAction();
        }
     }

</script>
</apex:page>

Regards

Raman

1

Go to SetUp -> Customize-> Account -> button , links and new action-> Edit the row with the name 'Edit' -> override with your VF page. Follow the same for your object.

The VF page will also have the id of the record that is being edited. Use the ID from the url to initialize the object that you want to display.

Just for testing you can try this:

Add this class and vf page(http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_standardcontroller.htm) in your org and then override the Edit link for account as shown in the below image.

Class:

public class myControllerExtension {

private final Account acct;

// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
    this.acct = (Account)stdController.getRecord();
}

public String getGreeting() {
    return 'Hello ' + acct.name + ' (' + acct.id + ')';
}
}

VF page:

<apex:page standardController="Account" extensions="myControllerExtension">
  {!greeting} <p/>
 <apex:form>
    <apex:inputField value="{!account.name}"/> <p/>
    <apex:commandButton value="Save" action="{!save}"/>
</ /apex:page>

enter image description here

0

@Raman I think your question is some what miss ledding so I will ans for both the cases that i think you may need..

  1. If you want a Link in your VF page and by clicking on that link you want the edit page of a particuler record to be open then you can just redirect the user to its standered edit page with a return URL.

  2. If you want a Link in your VF page and by clicking on that link you want to open the record in some other VF which should have the fields to be edited then, you may need to pass the Id of that record to that other VF page and Use this:

    ApexPages.currentPage().getParameters().get('Id') to get the Id in that other page and Query all the fields and display it in apex:InputField and use Save method from the StanderedContoller to Save that.

Hope that gives you a more clear Idea..

  • Thanks foe your reply, My concern is to redircect my page on the click of Edit which we got on the listview of Standard SalesForce page. One more thing How to get the ID of that record on the click of edit button. Please see the image also.... – Raman Jul 19 '13 at 9:47

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.