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
Ron-LONRon-LON 

Confused about multiple Opportunity lookups on VF page

Hi, 

 

I want to write a VF page that will combine Opportunity closeOpp and Opportunity keepOpp by taking all the products from closeOpp and putting them on keepOpp, then setting the stage on closeOpp to 'Closed.' 

 

I've written a class to do this quite nicely and it all works the way I like.  Now, I want to have a VF page on the front to call it.  I want to put two lookup fields:  one for the Opportunity to close and one for the opportunity to keep.

 

How do I set the respective variables in the class by using the standard Lookup functionality?

 

I thought I could put something like:

 

<apex:inputField value="{!closeOpp.Id}"/> 

<apex:inputField value="{!keepOpp.Id}"/>

 

 

public with sharing class opportunityMerge {

	public Opportunity closeOpp {get; set;}
	public Opportunity keepOpp {get; set;}
	List<OpportunityLineItem> newLines = new List<OpportunityLineItem>();


	public opportunityMerge() {
	
		 // might have to do something here depending on the suggestions
	}
	
	public void mergeOpps() { 
		// do all the heavy lifting here
		// loop the line items on closeOpp, clone them
		// add them to a list and insert them
	}

	public PageReference next() {
		// call mergeOpps from here
		return null;

	}

	public Pagereference cancel() {
		// cancel me
		return null;
	}
}

 

Thanks for any suggestions!!

 

:smileyhappy:

osamanosaman

Lookup field works when you have a lookup relationship with the object. I'd create two dropowns in your case once for each kind of Opportunity. And then select the opportunity from the dropdown. The value of the selectOption should be Opportunity Id.

 

Thanks