• Garrett Miller
  • NEWBIE
  • 45 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 22
    Replies

Hello all,
 

I have been searching through the documentation and I can't find a clear answer. I am trying to use apex to create a report ( it requires calculations that aren't available in the normal report building ), and I want to be able to save it as a public report. Is this possible? 

If so, would it require a Visualforce Page? 

I am trying to write a class to update an Account field whenever an Opportunity is Closed Won, but the field to update is based on a Detail object. 

Here is the situation. 

  • I have 3 objects: Account, Opportunity, and a custom object, Hand_Off__c
  • There is a master detail relationship between Account - Hand_Off__c
  • There is a master detail relationship between Opportunity - Hand_Off__c
  • A Hand_Off__c record is created whenever an Account's first Opportunity is Closed Won
  • There is a field on the Hand_Off__c record, Pricing_Structure__c 
  • There is a similar field,  Pricing_Structure__c, on the Account object
  • When the Hand_Off__c record is created and or updated, I want the Account.Pricing_Structure__c field to be populated with the Hand_Off__c.Pricing__Structure
What I have so far is:
public class HandsOffController {
    public static void setAccountDetailsFromHandOff(Set<ID> oppIds) {
        list<Account> modifiedAccounts = new List<Account>();
        list<Opportunity> handOffOpps = [SELECT Id, Account.Pricing_Structure__c, ( SELECT Id, Pricing_Structure__c	 FROM Hand_Off_to_Client_Success__r	) 	FROM Opportunity WHERE Id IN: oppIds AND stageName='Closed Won'];
        for (Opportunity o: handOffOpps) {
            if(o.Account.Pricing_Structure__c == null) {
                o.Account.Pricing_Structure__c = o.Pricing_Structure__c;
            }
        }
    }
}


I just don't know how to handle the Account-Detail relationship once I actually want to update the field.

Anyone have any tips?

Thanks!

Whenever an account's renewal date passes, someone has to manually enter an opportunity for an annual fee. I want to create a trigger/workflow rule/proccess that automates this, but I am unsure what the best way would be. There is no risk of the opportunity not being "Won" as it is just a fee. 

Does anyone have a suggestion on how to write a trigger for this? Or, is ther a better way than writing a trigger?

Best, 

Garrett

Hi All, 

I am trying to deploy a class to production, but there is a Class that I didn't create that is dragging down my overall code coverage. I am currently at 54% so I don't really want to write a ton of empty test classes, but I also don't know how to start writing this test class. 

Could anyone get my started on writing some unit tests for the Class below? I am fairly new to writing test classes. 

 

public with sharing class MassReassignOpportunitiesController {
	public ApexPages.StandardSetController optySetController;
	public String filterId {get;set;}
	public String ErrorMsg {get;set;}
	public String optyQueryString;
	public List<cOpty> optyList {get;set;}
	public list<Opportunity> optyToUpdateList {get;set;}
	public Opportunity searchRecord {get;set;}
	public Reassign_Helper__c helperRecord{get;set;}
	public boolean isSuccess{get;set;}
	public boolean searchPerformed{get;set;}
	public boolean tooManyResults{get;set;}
	
	public Integer optyListSize {get{return optylist.size();}}
	public list<SelectOption> listviewoptions {
		get{
			List<SelectOption> tempList = new List<SelectOption>();
			tempList.add(new selectOption('None',System.Label.NoViewSelection));
			if (optySetController<>null)tempList.addAll(optySetController.getListViewOptions());
			return tempList;
			}
	}

	public MassReassignOpportunitiesController(){
		
		//Variable Init
		optyQueryString = 'SELECT name,StageName,Ownerid,CloseDate from Opportunity where isDeleted=false';
		optyList = new List<cOpty>();
		optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 1000'));
		filterId = listviewoptions[0].getValue();
		searchRecord = new Opportunity();
		helperRecord = new Reassign_Helper__c();
		isSuccess=false;
		searchPerformed = false;
		tooManyResults= false;
		
		//Apply the default filter
		//refreshOptyList();
	}
	
	/*========================================
	Applies the View filter to the Opty List
	==========================================*/ 
	public void refreshOptyList(){
		list<Opportunity> testList = new list<Opportunity>();
		
		optyList.clear();
		isSuccess = false;
		tooManyResults = false;
		if (filterId <> null && filterId<> 'None'){
			 optySetController.setFilterId(filterId);
			 testList = (list<Opportunity>)optySetController.getRecords();
			 searchPerformed = true;
		} else searchPerformed = false;
		System.debug('Filter used=>'+filterId);
		System.debug('Result #=>'+optySetController.getResultSize());
		Integer counter=0;
		for (Opportunity opty:testList){
			optyList.add(new cOpty(Opty));
			counter++;
			if (counter==999){
				tooManyResults=true;
				 break;
			}
		}
		

		
	}
	
	public void refreshOptyListBySearch(){
		optyList.clear();
		isSuccess = false;
		
		//resultList = new List<cResult>();
		String userFilterQuery='';
		if (searchRecord.Name<>null) 	userFilterQuery = ' and Name like \'%'+searchRecord.Name+'%\'';
		if (searchRecord.Type<>null) 	userFilterQuery += ' and Type = \''+searchRecord.type+'\'';
		if (searchRecord.StageName<>null) 	userFilterQuery += ' and StageName = \''+searchRecord.StageName+'\'';
		if (helperRecord.From__c<>null){
				DateTime startDate = DateTime.newInstance(helperRecord.From__c, Time.newInstance(0, 0, 0, 0));
			 	userFilterQuery += ' and CreatedDate >= '+startDate.format('yyyy-MM-dd')+'T00:00:00Z';
			 	
		}
		if (helperRecord.To__c<>null){
				DateTime endDate = DateTime.newInstance(helperRecord.to__c, Time.newInstance(0, 0, 0, 0));
			 	userFilterQuery += ' and CreatedDate <= '+endDate.format('yyyy-MM-dd')+'T00:00:00Z';
		
		}
		if (helperRecord.closedDate_From__c<>null){
				DateTime startDate = DateTime.newInstance(helperRecord.closedDate_From__c, Time.newInstance(0, 0, 0, 0));
			 	userFilterQuery += ' and CloseDate >= '+startDate.format('yyyy-MM-dd');
			 	
		}
		if (helperRecord.closedDate_To__c<>null){
				DateTime endDate = DateTime.newInstance(helperRecord.closedDate_to__c, Time.newInstance(0, 0, 0, 0));
			 	userFilterQuery += ' and CloseDate <= '+endDate.format('yyyy-MM-dd');
		
		}
		
		String optyQueryString =optyQueryString +  userFilterQuery ;
		optyQueryString += ' order by Name limit 1000';
		
		List<Sobject> sortedResults= new List<SObject>();
		try{
			sortedResults = Database.query(optyQueryString);
			searchPerformed = true;
		} catch (Exception e){
			ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
		}
		System.debug('Requete => '+optyQueryString);

		for (SObject foundObject:sortedResults){
			Opportunity opty = (Opportunity)foundObject;
			optyList.add(new cOpty(opty));		
		}
	}
	
	
	/*===============================================
	Assign the selected opportunities to a new owner
	=================================================*/
	public void Assign(){     
        list<Opportunity> optyToUpdateList=new list<Opportunity>();
        list<Task> taskToUpdateList=new list<Task>();
        list<Event> eventToUpdateList = new List<Event>();
        for (cOpty opty:optyList)
            if (opty.selected)
                optyToUpdateList.add(new Opportunity(id=opty.oOpty.id, OwnerId=helperRecord.Assign_to__c));

        
        //We also need to reassign the open activities to the new owner
        //To do so, we first loop on all the opportunities to retrieve their Open Activities
        //Then we loop through the Task or Events and reassign them
        for(Opportunity tempOpty:[select id,(select id,isTask from OpenActivities order by ActivityDate DESC, LastModifiedDate DESC limit 500) from Opportunity where id in :optyToUpdateList]){
        	for (OpenActivity tempActivity:tempOpty.OpenActivities){
        		if (tempActivity.IsTask) taskToUpdateList.add(new Task(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
        		else EventToUpdateList.add(new Event(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
        	}
        }
        
        if (optyToUpdateList.size()+taskToUpdateList.size()+eventToUpdateList.size()>=10000) {
        	ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.TooManyRowsError));
        } else{
        
	        try
	        {
	            update optyToUpdateList;
	        }
	        catch (Exception e)
	        {
	            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
	        }
	        
	       	try
	        {
	            if (taskToUpdateList.size()>0) update taskToUpdateList;
	            if (eventToUpdateList.size()>0) update eventToUpdateList;
	        }
	        catch (Exception e)
	        {
	            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
	        }
        
	        // Update the search results
	        integer n=optyList.size();
	        for (integer i=n-1;i>=0;i--){
	            if (optyList[i].selected) optyList.remove(i);
			}
			
			if (optyToUpdateList.size()>0) isSuccess = true;
        }		
	}
	
	/*==================================================
	Inner class helping identify selected opportunities
	====================================================*/
	public class cOpty{
		public Opportunity oOpty {get;set;}
		public Boolean selected {get;set;}
		
		public cOpty(Opportunity oOpty){
			this.oOpty = oOpty;
			selected=false;
		}
		
	}
	
	
	public static testmethod void testReassign(){
		
		Account testAccount = new Account();
		testAccount.Name = 'test';
		insert testAccount;
		
		Opportunity testOpty = new Opportunity();
		testOpty.StageName = 'Discover';
		testOpty.CloseDate = System.today()+1;
		testOpty.AccountId=testAccount.Id;
		testOpty.Name='testOpty';
		testOpty.Type = 'testType';
		insert testOpty;
		
		MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController();
		controller.refreshOptyList();
		controller.filterId = controller.listviewoptions[1].getValue();
		controller.refreshOptyList();
		controller.searchRecord.stageName = 'Discover';
		controller.helperRecord.ClosedDate_From__c=System.today();
		controller.helperRecord.ClosedDate_To__c=System.today()+2;
		controller.helperRecord.From__c=System.today();
		controller.helperRecord.To__c=System.today()+1;
		controller.searchRecord.Type = 'testType';
		controller.refreshOptyListBySearch();
		
		System.assert(controller.optyList.size()>0);
		
		controller.optyList[0].selected = true;
		controller.helperRecord.Assign_to__c = UserInfo.getUserId();
		controller.Assign();
		
		
		
	}
	
	

}

I am just fairly confused at this point. 

Hi All,
I am trying to create a new Account field, Top_Pain_Points__c, that takes the same text value as a field, Top_Pain_Points__c on a custom object, Hands_Off_Form__c. The custom object is tied to a certain Opportunity and the value should copy over from the Custom Object to Account when the Opportunity is moved to closed won. 

I have created a workflow rule to perform this task, the rule is Opportunity Closed Won EQUALS True. 

The evaluation criteria is: Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria

The field update updates Account: Top Pain Points ( Data Type: Text Area )

The formula is: Formula Value (Text) = Top_Pain_Point__c 

I have done a few workflow rules before so I thought that I was doing everything right, but can someone see any flaws in my logic or have a better suggestion of how to go about this?

Thanks!

Garrett

Hi All, 


I am updating a field on one object based on another objects field being updated. They are "equal" in that they are contract lengths ranging from 1 year to 6 years. Unfortunately, the nature of my organization requires that for the field one object, the lanuage used is; annual, biennial, triennial, ... , sexennial. On the other object, the field is an integer from 1 to 6. 

My class just uses an if else to update the field to the string field. However, I am confused on how to perform this in the system.assert of my test class. I can't simply use:

System.assert(opp.Contract_Length__c == opp.Account.Renewal_Term__c, opp.Contract_Length__c+' is not equal to '+opp.Account.Renewal_Term__c);

As that would return 1 as not equal to Annual. Can I get some help on how to set up with portion of my test?

Best, 

Garrett

 

Hi All, 

I am trying to get used to writing triggers doing a fairly simple trigger but I am stuck. 

I am trying to write a trigger where te scenario is:

  1.  Two objects Account and Opportunity
  2. Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
  3. Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
  4. I believe that there is a master-detail relationship between Account and Opportunity
  5. When an Opportunity is Closed Won, Renewal Term should update to the corresponding contract length from the Opportunity, provided that Renewal Term isn't already populated. 

Embarrassingly, all I have so far is:

 

    

trigger updatelength on Account (after update) {
    Opportunity__c[] opptoupdate = new Opporunity__c[]{};
        for(account c: trigger.new){
            for(Opportunity__c cp: [select id,name,Contract_Length__c from Opportunity__c where Account = :c.id]{

            }
        }
}


Would anyone mind helping me out?

Thanks!

Hi All, 

I am trying to get used to writing triggers doing a fairly simple trigger but I am stuck. 

I am trying to write a trigger where te scenario is:

  1.  Two objects Account and Opportunity
  2. Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
  3. Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
  4. I believe that there is a master-detail relationship between Account and Opportunity
  5. When an Opportunity is Closed Won, Renewal Term should update to the corresponding contract length from the Opportunity, provided that Renewal Term isn't already populated. 

Embarrassingly, all I have so far is:

 

    

trigger updatelength on Account (after update) {
    Opportunity__c[] opptoupdate = new Opporunity__c[]{};
        for(account c: trigger.new){
            for(Opportunity__c cp: [select id,name,Contract_Length__c from Opportunity__c where Account = :c.id]{

            }
        }
}


Would anyone mind helping me out?

Thanks!

I am trying to write a class to update an Account field whenever an Opportunity is Closed Won, but the field to update is based on a Detail object. 

Here is the situation. 

  • I have 3 objects: Account, Opportunity, and a custom object, Hand_Off__c
  • There is a master detail relationship between Account - Hand_Off__c
  • There is a master detail relationship between Opportunity - Hand_Off__c
  • A Hand_Off__c record is created whenever an Account's first Opportunity is Closed Won
  • There is a field on the Hand_Off__c record, Pricing_Structure__c 
  • There is a similar field,  Pricing_Structure__c, on the Account object
  • When the Hand_Off__c record is created and or updated, I want the Account.Pricing_Structure__c field to be populated with the Hand_Off__c.Pricing__Structure
What I have so far is:
public class HandsOffController {
    public static void setAccountDetailsFromHandOff(Set<ID> oppIds) {
        list<Account> modifiedAccounts = new List<Account>();
        list<Opportunity> handOffOpps = [SELECT Id, Account.Pricing_Structure__c, ( SELECT Id, Pricing_Structure__c	 FROM Hand_Off_to_Client_Success__r	) 	FROM Opportunity WHERE Id IN: oppIds AND stageName='Closed Won'];
        for (Opportunity o: handOffOpps) {
            if(o.Account.Pricing_Structure__c == null) {
                o.Account.Pricing_Structure__c = o.Pricing_Structure__c;
            }
        }
    }
}


I just don't know how to handle the Account-Detail relationship once I actually want to update the field.

Anyone have any tips?

Thanks!

Whenever an account's renewal date passes, someone has to manually enter an opportunity for an annual fee. I want to create a trigger/workflow rule/proccess that automates this, but I am unsure what the best way would be. There is no risk of the opportunity not being "Won" as it is just a fee. 

Does anyone have a suggestion on how to write a trigger for this? Or, is ther a better way than writing a trigger?

Best, 

Garrett

Hi All,
I am trying to create a new Account field, Top_Pain_Points__c, that takes the same text value as a field, Top_Pain_Points__c on a custom object, Hands_Off_Form__c. The custom object is tied to a certain Opportunity and the value should copy over from the Custom Object to Account when the Opportunity is moved to closed won. 

I have created a workflow rule to perform this task, the rule is Opportunity Closed Won EQUALS True. 

The evaluation criteria is: Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria

The field update updates Account: Top Pain Points ( Data Type: Text Area )

The formula is: Formula Value (Text) = Top_Pain_Point__c 

I have done a few workflow rules before so I thought that I was doing everything right, but can someone see any flaws in my logic or have a better suggestion of how to go about this?

Thanks!

Garrett

Hi All, 

I am trying to get used to writing triggers doing a fairly simple trigger but I am stuck. 

I am trying to write a trigger where te scenario is:

  1.  Two objects Account and Opportunity
  2. Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
  3. Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
  4. I believe that there is a master-detail relationship between Account and Opportunity
  5. When an Opportunity is Closed Won, Renewal Term should update to the corresponding contract length from the Opportunity, provided that Renewal Term isn't already populated. 

Embarrassingly, all I have so far is:

 

    

trigger updatelength on Account (after update) {
    Opportunity__c[] opptoupdate = new Opporunity__c[]{};
        for(account c: trigger.new){
            for(Opportunity__c cp: [select id,name,Contract_Length__c from Opportunity__c where Account = :c.id]{

            }
        }
}


Would anyone mind helping me out?

Thanks!

Hey, could anybody differentiate system.assert methods and when to use them. Clear explanation is greatly appreciated

i can't deploy code to production because production has 63% coverage, and the class with 0% coverage is this.

 

http://appexchange.salesforce.com/listingDetail?listingId=a0N30000003JEIpEAO

 

how do i get past this? this is an app that was downloaded to production from the appexchange... i dont have the slightest idea how to start test coverage.

 

public with sharing class MassReassignOpportunitiesController {
  public ApexPages.StandardSetController optySetController;
  public String filterId {get;set;}
  public String ErrorMsg {get;set;}
  public String optyQueryString;
  public List<cOpty> optyList {get;set;}
  public list<Opportunity> optyToUpdateList {get;set;}
  public Opportunity searchRecord {get;set;}
  public Reassign_Helper__c helperRecord{get;set;}
  public boolean isSuccess{get;set;}
  public boolean searchPerformed{get;set;}
  public boolean tooManyResults{get;set;}
  
  public Integer optyListSize {get{return optylist.size();}}
  public list<SelectOption> listviewoptions {
    get{
      List<SelectOption> tempList = new List<SelectOption>();
      tempList.add(new selectOption('None',System.Label.NoViewSelection));
      if (optySetController<>null)tempList.addAll(optySetController.getListViewOptions());
      return tempList;
      }
  }

  public MassReassignOpportunitiesController(){
    
    //Variable Init
    optyQueryString = 'SELECT name,StageName,Ownerid,CloseDate from Opportunity where isDeleted=false';
    optyList = new List<cOpty>();
    optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 1000'));
    filterId = listviewoptions[0].getValue();
    searchRecord = new Opportunity();
    helperRecord = new Reassign_Helper__c();
    isSuccess=false;
    searchPerformed = false;
    tooManyResults= false;
    
    //Apply the default filter
    //refreshOptyList();
  }
  
  /*========================================
  Applies the View filter to the Opty List
  ==========================================*/ 
  public void refreshOptyList(){
    list<Opportunity> testList = new list<Opportunity>();
    
    optyList.clear();
    isSuccess = false;
    tooManyResults = false;
    if (filterId <> null && filterId<> 'None'){
       optySetController.setFilterId(filterId);
       testList = (list<Opportunity>)optySetController.getRecords();
       searchPerformed = true;
    } else searchPerformed = false;
    System.debug('Filter used=>'+filterId);
    System.debug('Result #=>'+optySetController.getResultSize());
    Integer counter=0;
    for (Opportunity opty:testList){
      optyList.add(new cOpty(Opty));
      counter++;
      if (counter==999){
        tooManyResults=true;
         break;
      }
    }
    

    
  }
  
  public void refreshOptyListBySearch(){
    optyList.clear();
    isSuccess = false;
    
    //resultList = new List<cResult>();
    String userFilterQuery='';
    if (searchRecord.Name<>null)   userFilterQuery = ' and Name like \'%'+searchRecord.Name+'%\'';
    if (searchRecord.Type<>null)   userFilterQuery += ' and Type = \''+searchRecord.type+'\'';
    if (searchRecord.StageName<>null)   userFilterQuery += ' and StageName = \''+searchRecord.StageName+'\'';
    if (helperRecord.From__c<>null){
        DateTime startDate = DateTime.newInstance(helperRecord.From__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CreatedDate >= '+startDate.format('yyyy-MM-dd')+'T00:00:00Z';
         
    }
    if (helperRecord.To__c<>null){
        DateTime endDate = DateTime.newInstance(helperRecord.to__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CreatedDate <= '+endDate.format('yyyy-MM-dd')+'T00:00:00Z';
    
    }
    if (helperRecord.closedDate_From__c<>null){
        DateTime startDate = DateTime.newInstance(helperRecord.closedDate_From__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CloseDate >= '+startDate.format('yyyy-MM-dd');
         
    }
    if (helperRecord.closedDate_To__c<>null){
        DateTime endDate = DateTime.newInstance(helperRecord.closedDate_to__c, Time.newInstance(0, 0, 0, 0));
         userFilterQuery += ' and CloseDate <= '+endDate.format('yyyy-MM-dd');
    
    }
    
    String optyQueryString =optyQueryString +  userFilterQuery ;
    optyQueryString += ' order by Name limit 1000';
    
    List<Sobject> sortedResults= new List<SObject>();
    try{
      sortedResults = Database.query(optyQueryString);
      searchPerformed = true;
    } catch (Exception e){
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
    System.debug('Requete => '+optyQueryString);

    for (SObject foundObject:sortedResults){
      Opportunity opty = (Opportunity)foundObject;
      optyList.add(new cOpty(opty));    
    }
  }
  
  
  /*===============================================
  Assign the selected opportunities to a new owner
  =================================================*/
  public void Assign(){     
        list<Opportunity> optyToUpdateList=new list<Opportunity>();
        list<Task> taskToUpdateList=new list<Task>();
        list<Event> eventToUpdateList = new List<Event>();
        for (cOpty opty:optyList)
            if (opty.selected)
                optyToUpdateList.add(new Opportunity(id=opty.oOpty.id, OwnerId=helperRecord.Assign_to__c));

        
        //We also need to reassign the open activities to the new owner
        //To do so, we first loop on all the opportunities to retrieve their Open Activities
        //Then we loop through the Task or Events and reassign them
        for(Opportunity tempOpty:[select id,(select id,isTask from OpenActivities order by ActivityDate DESC, LastModifiedDate DESC limit 500) from Opportunity where id in :optyToUpdateList]){
          for (OpenActivity tempActivity:tempOpty.OpenActivities){
            if (tempActivity.IsTask) taskToUpdateList.add(new Task(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
            else EventToUpdateList.add(new Event(id=tempActivity.id,ownerId=helperRecord.Assign_to__c));
          }
        }
        
        if (optyToUpdateList.size()+taskToUpdateList.size()+eventToUpdateList.size()>=10000) {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.TooManyRowsError));
        } else{
        
          try
          {
              update optyToUpdateList;
          }
          catch (Exception e)
          {
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
          }
          
           try
          {
              if (taskToUpdateList.size()>0) update taskToUpdateList;
              if (eventToUpdateList.size()>0) update eventToUpdateList;
          }
          catch (Exception e)
          {
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
          }
        
          // Update the search results
          integer n=optyList.size();
          for (integer i=n-1;i>=0;i--){
              if (optyList[i].selected) optyList.remove(i);
      }
      
      if (optyToUpdateList.size()>0) isSuccess = true;
        }    
  }
  
  /*==================================================
  Inner class helping identify selected opportunities
  ====================================================*/
  public class cOpty{
    public Opportunity oOpty {get;set;}
    public Boolean selected {get;set;}
    
    public cOpty(Opportunity oOpty){
      this.oOpty = oOpty;
      selected=false;
    }
    
  }
  
  
  public static testmethod void testReassign(){
    
    Account testAccount = new Account();
    testAccount.Name = 'test';
    insert testAccount;
    
    Opportunity testOpty = new Opportunity();
    testOpty.StageName = 'Discover';
    testOpty.CloseDate = System.today()+1;
    testOpty.AccountId=testAccount.Id;
    testOpty.Name='testOpty';
    testOpty.Type = 'testType';
    insert testOpty;
    
    MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController();
    controller.refreshOptyList();
    controller.filterId = controller.listviewoptions[1].getValue();
    controller.refreshOptyList();
    controller.searchRecord.stageName = 'Discover';
    controller.helperRecord.ClosedDate_From__c=System.today();
    controller.helperRecord.ClosedDate_To__c=System.today()+2;
    controller.helperRecord.From__c=System.today();
    controller.helperRecord.To__c=System.today()+1;
    controller.searchRecord.Type = 'testType';
    controller.refreshOptyListBySearch();
    
    System.assert(controller.optyList.size()>0);
    
    controller.optyList[0].selected = true;
    controller.helperRecord.Assign_to__c = UserInfo.getUserId();
    controller.Assign();
    
    
    
  }
  
  

}