-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
7Questions
-
22Replies
Can I create and save a public report with Apex?
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?
- Garrett Miller
- June 22, 2017
- Like
- 0
- Continue reading or reply
Update Field on Master Detail Relationship?
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
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!
- Garrett Miller
- June 21, 2017
- Like
- 0
- Continue reading or reply
Can I write a trigger that adds a Fee Opportunity whenever an account's renewal date passes?
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
- Garrett Miller
- June 08, 2017
- Like
- 0
- Continue reading or reply
MassReassignOpportunitiesController Test Class
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.
- Garrett Miller
- May 25, 2017
- Like
- 0
- Continue reading or reply
Create Account field with same value as Custom Object field based on Opportunity
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
- Garrett Miller
- May 22, 2017
- Like
- 0
- Continue reading or reply
How can I use System.assert on a case basis?
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
- Garrett Miller
- May 17, 2017
- Like
- 0
- Continue reading or reply
Update Field Between Account and Opportunity
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:
- Two objects Account and Opportunity
- Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
- Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
- I believe that there is a master-detail relationship between Account and Opportunity
- 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!
- Garrett Miller
- May 08, 2017
- Like
- 1
- Continue reading or reply
Update Field Between Account and Opportunity
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:
- Two objects Account and Opportunity
- Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
- Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
- I believe that there is a master-detail relationship between Account and Opportunity
- 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!
- Garrett Miller
- May 08, 2017
- Like
- 1
- Continue reading or reply
Update Field on Master Detail Relationship?
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
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!
- Garrett Miller
- June 21, 2017
- Like
- 0
- Continue reading or reply
Can I write a trigger that adds a Fee Opportunity whenever an account's renewal date passes?
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
- Garrett Miller
- June 08, 2017
- Like
- 0
- Continue reading or reply
Create Account field with same value as Custom Object field based on Opportunity
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
- Garrett Miller
- May 22, 2017
- Like
- 0
- Continue reading or reply
Update Field Between Account and Opportunity
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:
- Two objects Account and Opportunity
- Account field Renewal Term (Renewal_Term__c)that is picklist of years annual through sexennial
- Opportunity Field Contract Length ( Contract_Length__c ) that is a picklist of values 1-6
- I believe that there is a master-detail relationship between Account and Opportunity
- 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!
- Garrett Miller
- May 08, 2017
- Like
- 1
- Continue reading or reply
System.assert(Methods)
- Rod Tucker
- July 21, 2016
- Like
- 0
- Continue reading or reply
MassReassignOpportunitiesController
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(); } }
- Glen.ax1034
- August 18, 2011
- Like
- 0
- Continue reading or reply