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
sales4cesales4ce 

Returned Data in a Data Table must have hyperlinks or reference

Hi,

 

I have a custom search Page, which looks at a criteria ans then returns a result to the visualforce page back in Pageblock Table.

The returned result now does not have any reference and you cannot click on any data to view the detail page.

 

How can i return data as a hyperlink to click on it to view detail page?

 

Any idea / help is highly appreciated.

 

VF Page:

 

<apex:page standardController="Account" extensions="SearchAccounts" >
    <apex:form >
        <div style="border-width:2px;border-style:solid;border-color:blue;">
            <apex:sectionHeader Title=" Step 1" subtitle="Search For Already Existing Accounts" />
         </div>
      
        <br/>
        <apex:PageBlock Title="Search Accounts">
            <apex:PageBlockSection columns="1">          
             <apex:inputField value="{!newAcct.Name}"/>  
             <apex:InputField value="{!newAcct.Site}"/>
             <apex:inputField value="{!newAcct.BillingCity}"/>
             
             </apex:PageBlockSection>                                                                                                                                       
       
        <div style="position:relative;left:230px;">
             <apex:commandButton value="Next" action="{!SearchAccount}" /> &nbsp;&nbsp;
             <apex:commandButton value="Cancel" />
        </div>  
        
        <!-- Display error message -->
             <apex:pagemessage strength="2" title="Error!!" severity="error" detail="An Account(s) Already Exists !!!" rendered="{!errormsg}"/><!-- End of error message -->
             
            <apex:pageBlockTable value="{!Results}" var="Accts" rendered="{!NOT(ISNULL(Results))}" title="Search Results">
                <apex:column headerValue="Account Name">
                    <apex:outputText value="{!Accts.Name}">
                    </apex:outputText>
                 </apex:column>
                 <apex:column headerValue="Account Site">
                    <apex:outputText value="{!Accts.Site}">
                    </apex:outputText>
                 </apex:column>
                 <apex:column headerValue="Billing City">
                    <apex:outputText value="{!Accts.BillingCity}">
                    </apex:outputText>
                 </apex:column>
            </apex:pageBlockTable>
         </apex:PageBlock>
                      
    </apex:form>
  
</apex:page>

Apex Class:

 

public class SearchAccounts {
    
     Public Account newAcct=new Account();
    public SearchAccounts(ApexPages.StandardController controller) 
    {
        

    }
    Public boolean errormsg=false;
    Public List<Account> checkDuplicates;
   
    
    Public Account getnewAcct()
    {
        return newAcct;
    }
    
     public List<Account> getResults(){
         return checkDuplicates;
        }
    
    
    
    Public Pagereference SearchAccount()
    {
        checkDuplicates=[Select Name, BillingCity, Site FROM Account where Name=:newAcct.Name And Site=:newAcct.Site And BillingCity=:newAcct.Billingcity ];
        System.Debug('Size=='+checkDuplicates.Size());
        System.Debug('Name=='+newAcct.Name);
        System.Debug('Name=='+newAcct.Site);
        if(checkDuplicates.Size()==0)
        {
            PageReference newAccount=new Pagereference('/001/e?nooverride=true');
            return newAccount;
        }
        Else
        {
        
            errormsg=true;
            return NULL;
         }
    }
    
    Public Boolean geterrormsg()
    {
        return errormsg;
    }
}

 

 

 

Thanks,

Sales4ce

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

Try a workaround as per the code given below for getting the view of the record on the click of Account Name :

 

            <apex:column >

              <apex:outputLink value="/{!Accts.Id}">{!Accts.name}</apex:outputLink>

                <apex:facet> Contact Name</apex:facet>

           </apex:column>

 

Hope this helps.

All Answers

gtuerkgtuerk

Use an apex:outputLink. In below snippet, replace the bind notation with your accessor

<apex:column headerValue="Name" >
<apex:outputLink value="/{!RelatedISOVO.iso.Id}" target="_top" >{!RelatedISOVO.iso.Name}</apex:outputLink>
</apex:column>

Pradeep_NavatarPradeep_Navatar

Try a workaround as per the code given below for getting the view of the record on the click of Account Name :

 

            <apex:column >

              <apex:outputLink value="/{!Accts.Id}">{!Accts.name}</apex:outputLink>

                <apex:facet> Contact Name</apex:facet>

           </apex:column>

 

Hope this helps.

This was selected as the best answer