+ Start a Discussion
Neema Gudur 8Neema Gudur 8 

Adding links to custom rich text area on an object

Hello,
I have the following requirement.
Create a custom button on the opportunity object. The opportunity object has custom fields (street,city,state,zip,country)When the button is clicked , open a visual force page in a new window and display the address information on the page.
I could pass the address values as parameters to the new window. The visual force page also has a button 'Search'. When the search button is clicked, it will search for opportunities within a mile and display results in a page block table with checkboxes next to each row. Each row in the table has opportunity name and other columns The user should be able to select the checkboxes and clicking Ok, should include the Opportunity name as links in a custom rich text field on the opportunity.
I am trying to figure out the best possible way to pass the opportunity id's/names from the visual force page to the opportunity page when the user selects the checkboxes and clicks OK.
Any help is highly appreciated.

 
Dario BakDario Bak
I think you need to create a standard Controller for this. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std.htm

1) When click search, ID is passed with no extra work
2) When click SAVE, you fire a Controller method and save the data as you want it.

Makes sense?
If so, please mark as best solution!
VineetKumarVineetKumar
Use below tag in your page, to make your opportunity name as an hyperlink to the opportunity record.
<apex:outputLink value="{!Opportunity.Id}"> Opportunity Name </apex:outputLink>
Let me know if it helped.
The best way to pass the value from the VF page to the controller for you selection would the use of wrapper classes.
Pseudo code below :
 
PAGE:
<apex:pageBlockTable value="{!owList}" var="thisow">
	<apex:column headerValue="Select">{!thisow.isSelected}</apex:column>
	<apex:column headerValue="Opportunity Name">{!thisow.opportunityRecord.Name}</apex:column>   		
</apex:pageBlockTable>

CONTROLLER:	
	public List<SelectOption> getItems() {
		List<SelectOption> options = new List<SelectOption>(); 
		options.add(new SelectOption('1','1')); 
		options.add(new SelectOption('2','2')); 
		options.add(new SelectOption('3','3')); 
		return options; 
	}

	public List<OpportunityWrapper> owList = new List<OpportunityWrapper>();
	public class OpportunityWrapper{
		public Opportunity opportunityRecord {get; set;}
		public Boolean isSelected {get; set;}
		
		public OpportunityWrapper(Opportunity opportunityRecord, Boolean isSelected){
			this.opportunityRecord = opportunityRecord;
			this.isSelected = isSelected;		
		}
	}
	List<Opportunity> selectedOpportunityList = new List<Opportunity>();
	public pagereference save(){
		for(OpportunityWrapper thisow : owList){
			if(thisow.isSelected){
				selectedOpportunityList.add(thisow);
			}
		}
		system.debug('Selected Records:' +selectedOpportunityList); 
		return Null;
	}
}

Let me know if this helps.
Neema Gudur 8Neema Gudur 8
Thank You Darlo and Vineet. I am having trouble with pagination. I cannot use Standard set controller as the wrapper object is not an SObject. How did you get around pagination for wrapper objects?
VineetKumarVineetKumar
Implement custom pagination.
Either through jquery or a totally custom thing in your controller.