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
s-Forces-Force 

How we pass the values on visual force page.

Hello,

 

I am facing problem in passing the values on visual force page. actually i want when i select one value from the lookup field, it will automatically give its related values or other values saved in that on visual force page.

 

e.g.

Suppose i have registred myself for hostel and when they select my name form lookup filed of students. it gives my whole detail on same page automatically.

please anyone give me example code for the same. i need it urgently.

 

Thanks In Advance.

SargeSarge

Hi,

 

   You can use <apex:detail/> tag for the same.  Using the same example you provided, lets say that there is a lookup field in Hostel named Student__c then you can show the detailed informationas follows

 

<apex:detail subject="{!Hostel__c.Student__c}" />

 

Hope this helps.

s-Forces-Force

Thanks for ur reply dear,

 

 but pls if you have full example code for the same pls post it.....

 

Thanks.

DanCurryJrDanCurryJr

Here's some code that I've writtent that adds packages to a quote based on the package or product family chosen by the sales rep:

 

<apex:page standardController="Quote__c" extensions="addProducts" sidebar="false" id="quote">
<apex:param name="display" value="true" />
<apex:form >
    <apex:pageblock title="Quote Number:  {!Quote__c.name}">
        <apex:pageBlockButtons >
            <apex:commandbutton action="{!save}" value="Save" />
            <apex:commandbutton action="{!cancel}" value="Cancel" />
            <apex:commandbutton action="{!delete}" value="Delete" />
            <apex:commandbutton action="{!sync}" value="Sync to Opportunity" />
        </apex:pageBlockButtons>
        <apex:outputpanel id="detail">
            <apex:outputlabel value="Price:  " for="price" /> <apex:inputfield id="price" value="{!Quote__c.Price__c}" /><br />
            <apex:outputlabel value="Renewal:  " for="renewal" /> <apex:inputfield id="renewal" value="{!Quote__c.Renewal__c}" /><br />
            <apex:outputlabel value="Account:  " for="Account" /> <apex:inputfield id="Account" value="{!Quote__c.Account__c}" /><br />
            <apex:outputlabel value="Opportunity:  " for="Opportunity" /> <apex:inputfield id="Opportunity" value="{!Quote__c.Opportunity__c}" /><br />
            <apex:outputlabel value="Valid Through:  " for="Valid" /> <apex:inputfield id="Valid" value="{!Quote__c.Valid_Through__c}" /><br />
        </apex:outputpanel>
    </apex:pageblock>
    <apex:pageblock >
        <apex:outputlabel value="Product Family " for="values" />
        <apex:outputpanel id="firstvalue"><apex:selectList value="{!template}" size="1" id="values">
            <apex:actionSupport event="onchange" reRender="newvalue" />
            <apex:selectOptions value="{!templates}"/>
            </apex:selectList>
        </apex:outputpanel>
        <apex:outputpanel id="newvalue">
            <apex:outputpanel rendered="{!template != ''}">
                <apex:outputlabel value="Package " for="products" />
                    <apex:selectList value="{!label}" size="1" id="products">
                    <apex:selectOptions value="{!products}"/>
                    </apex:selectList>
      <apex:commandbutton action="{!add}" value="Add">
          <apex:actionSupport event="onclick" reRender="output" />
      </apex:commandbutton>
                </apex:outputpanel>
        </apex:outputpanel>
    </apex:pageblock>
</apex:form>
<apex:pageblock >
        <apex:outputpanel id="output">
        <apex:form >
            <apex:repeat value="{!realpackages}" var="a" >
                <apex:commandLink action="{!remove}" id="theCommandLink" style="color: #cc0000; text-decoration: none;" rerender="output">
                    <apex:param name="aid" value="{!a.id}"/>
                &nbsp;[delete]&nbsp;</apex:commandLink> {!a.Name}<br />
            </apex:repeat>
        </apex:form>
        </apex:outputpanel>
</apex:pageblock>
        <apex:relatedList list="notesandattachments" />
<div style="width: 100%; position: relative; float: right;">
    <a href="/apex/manageproducts?id={!Quote__c.id}" style="float: right; text-decoration: none; color: #009966;">GO TO STEP 2 of 5  --></a>
</div>
</apex:page>

DanCurryJrDanCurryJr
s-Forces-Force

Hey.. Thanks for reply.

 

But still am getting problem. and now am facing some problem. pls solve it if you have any idea about this.

 

e.g.

 i have a tab for company setup. am entering all detail of company in this. and one another tab i.e. payment entry. i want when i select the payment entry tab it shows the comapny name automatically as header.

please tell me hows its possible.:(

 

Thanks in Advance

SargeSarge

Hi,

 

  Please post your new problem in a new thread so right ppl can address a single problem.

 

Code for displaying detail information is here: I have taken Contact and Account as an example. Here you have contact's lookup field for Account. If you select any account, and click the button, you will see the detail page for that selected account.

 

 

<apex:page standardController="Contact">
  <apex:pageMessages></apex:pageMessages>
  <apex:form>
      <apex:pageBlock>
          <apex:pageBlockSection columns="1">
              <apex:pageBlockSectionItem>
                  <apex:outputText>Select a Account</apex:outputText>
                  <apex:outputPanel>
                      <!--lookup field of contact. Lookup to Accounts-->
                      <apex:inputField value="{!Contact.AccountId}"/>
                      <apex:commandButton value="Show Account" reRender="accountDetailPanel"/>
                  </apex:outputPanel>
              </apex:pageBlockSectionItem>
              <apex:outputPanel id="accountDetailPanel">
                  <apex:detail subject="{!Contact.AccountId}" relatedList="false" rendered="{!IF(LEN(Contact.AccountId) > 0,true,false)}" />
              </apex:outputPanel>
          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

 Hope this example helps you.