- dburks_goosehead
- NEWBIE
- 25 Points
- Member since 2012
- Director of Information Systems
-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
5Replies
Opportunity Trigger
Question:
Would trigger be the best way to go about this? Are there any gotchas(with bulk account updates) that I should watch out for? Any other method to build this scenario more efficiently?
- V R 9
- January 30, 2015
- Like
- 0
- Continue reading or reply
Reporting Module?
1. Why would this not already exist?
2. Any idea if this is in the works?
- dburks_goosehead
- April 14, 2015
- Like
- 0
- Continue reading or reply
Test Class for basic Controller Extension
public with sharing class controlOppty {
public Case c;
public Opportunity oppty;
private ApexPages.StandardController stdController;
public controlOppty(ApexPages.StandardController controller) {
this.c= (Case)controller.getRecord();
this.oppty= c.Opportunity_Name__r ;
this.stdController= controller;
}
public PageReference saveRecord() {
PageReference ret = stdController.save();
system.assertNotEquals(null, c.Id);
update oppty;
update c;
return ret;
}
}
I've written this:
@isTest
private class TestControlOppty{
static testMethod void TestControlOppty() {
Opportunity testOpportunity = new Opportunity();
testOpportunity.Name = 'Test Opportunity For Test user';
testOpportunity.StageName = 'Quoted';
testOpportunity.LeadSource = 'Referral';
testOpportunity.OwnerId = UserInfo.getUserId();
testOpportunity.CloseDate = System.today();
testOpportunity.RecordTypeID = '01280000000BJpn';
testOpportunity.Amount = Integer.valueOf(Math.random() * 1000);
testOpportunity.Policy_Type__c = 'Home';
testOpportunity.Policy_Type_Level_II__c = 'Home';
testOpportunity.Proof_of_Alarm__c = true;
testOpportunity.Proof_of_Prior__c = false;
testOpportunity.Proof_of_Flood_Coverage__c = false;
testOpportunity.Proof_of_Garaging_Address__c = true;
testOpportunity.Proof_of_Home_Ownership__c = false;
testOpportunity.Proof_of_Garaging_Address__c = false;
testOpportunity.Proof_of_Health_Insurance__c = false;
testOpportunity.Proof_of_New_Purchase__c = false;
testOpportunity.Proof_of_Residency__c = false;
testOpportunity.Proof_of_Wind_Coverage__c = false;
testOpportunity.Good_Student_Discount__c = true;
testOpportunity.Defensive_Driving_Cert__c = true;
testOpportunity.Appraisal_For_Scheduled_Property__c = true;
testOpportunity.Roof_Certificate__c = true;
testOpportunity.Bill_of_Sale__c = false;
testOpportunity.X4_Point_Inspection__c = true;
testOpportunity.Wind_Mitigation_Certificate__c = true;
testOpportunity.Photos__c = false;
testOpportunity.Other_Trailing_Doc__c = 'Document';
insert testOpportunity;
Test.startTest();
Case c1 = new Case(Opportunity_Name__c = testOpportunity.Id, Subject = 'Test Case', Status = 'New', Due_Date__c = system.today(), Outcome__c = 'Document Received');
insert c1;
ApexPages.currentPage().getParameters().put('id',c1.id);
ApexPages.StandardController sc = new ApexPages.StandardController(c1);
ControlOppty conOpp = new ControlOppty(sc);
update c1;
update testOpportunity;
List<Case> c = [SELECT Id FROM Case];
System.assertEquals(c.size(),1);
Test.stopTest();
}
}
And have coverage for:
Any help getting these lines covered is appreciated.
- dburks_goosehead
- January 30, 2015
- Like
- 0
- Continue reading or reply
Conditionally Display an Image on Visualforce Page
I created the code below to display an image - I use this as a visualforce element on a page layout.
<apex:page standardController="Carrier__c" >
<img src="{!$Resource.SafecoMap}" width="772" height="496"/>,
</apex:page>
What I need to do is add logic to display the correct image depending on the name of the record so something like:
<apex:page standardController="Carrier__c" >
IF Carrier__c.Name="Safeco", <img src="{!$Resource.SafecoMap}" width="772" height="496"/>,
IF Carrier__c.Name=...
</apex:page>
This way I can display the appropriate image for each carrier record. Does anyone know the correct syntax to accomplish this?
- dburks_goosehead
- May 01, 2012
- Like
- 0
- Continue reading or reply
Reporting Module?
1. Why would this not already exist?
2. Any idea if this is in the works?
- dburks_goosehead
- April 14, 2015
- Like
- 0
- Continue reading or reply
Test Class for basic Controller Extension
public with sharing class controlOppty {
public Case c;
public Opportunity oppty;
private ApexPages.StandardController stdController;
public controlOppty(ApexPages.StandardController controller) {
this.c= (Case)controller.getRecord();
this.oppty= c.Opportunity_Name__r ;
this.stdController= controller;
}
public PageReference saveRecord() {
PageReference ret = stdController.save();
system.assertNotEquals(null, c.Id);
update oppty;
update c;
return ret;
}
}
I've written this:
@isTest
private class TestControlOppty{
static testMethod void TestControlOppty() {
Opportunity testOpportunity = new Opportunity();
testOpportunity.Name = 'Test Opportunity For Test user';
testOpportunity.StageName = 'Quoted';
testOpportunity.LeadSource = 'Referral';
testOpportunity.OwnerId = UserInfo.getUserId();
testOpportunity.CloseDate = System.today();
testOpportunity.RecordTypeID = '01280000000BJpn';
testOpportunity.Amount = Integer.valueOf(Math.random() * 1000);
testOpportunity.Policy_Type__c = 'Home';
testOpportunity.Policy_Type_Level_II__c = 'Home';
testOpportunity.Proof_of_Alarm__c = true;
testOpportunity.Proof_of_Prior__c = false;
testOpportunity.Proof_of_Flood_Coverage__c = false;
testOpportunity.Proof_of_Garaging_Address__c = true;
testOpportunity.Proof_of_Home_Ownership__c = false;
testOpportunity.Proof_of_Garaging_Address__c = false;
testOpportunity.Proof_of_Health_Insurance__c = false;
testOpportunity.Proof_of_New_Purchase__c = false;
testOpportunity.Proof_of_Residency__c = false;
testOpportunity.Proof_of_Wind_Coverage__c = false;
testOpportunity.Good_Student_Discount__c = true;
testOpportunity.Defensive_Driving_Cert__c = true;
testOpportunity.Appraisal_For_Scheduled_Property__c = true;
testOpportunity.Roof_Certificate__c = true;
testOpportunity.Bill_of_Sale__c = false;
testOpportunity.X4_Point_Inspection__c = true;
testOpportunity.Wind_Mitigation_Certificate__c = true;
testOpportunity.Photos__c = false;
testOpportunity.Other_Trailing_Doc__c = 'Document';
insert testOpportunity;
Test.startTest();
Case c1 = new Case(Opportunity_Name__c = testOpportunity.Id, Subject = 'Test Case', Status = 'New', Due_Date__c = system.today(), Outcome__c = 'Document Received');
insert c1;
ApexPages.currentPage().getParameters().put('id',c1.id);
ApexPages.StandardController sc = new ApexPages.StandardController(c1);
ControlOppty conOpp = new ControlOppty(sc);
update c1;
update testOpportunity;
List<Case> c = [SELECT Id FROM Case];
System.assertEquals(c.size(),1);
Test.stopTest();
}
}
And have coverage for:
Any help getting these lines covered is appreciated.
- dburks_goosehead
- January 30, 2015
- Like
- 0
- Continue reading or reply
Opportunity Trigger
Question:
Would trigger be the best way to go about this? Are there any gotchas(with bulk account updates) that I should watch out for? Any other method to build this scenario more efficiently?
- V R 9
- January 30, 2015
- Like
- 0
- Continue reading or reply
Conditionally Display an Image on Visualforce Page
I created the code below to display an image - I use this as a visualforce element on a page layout.
<apex:page standardController="Carrier__c" >
<img src="{!$Resource.SafecoMap}" width="772" height="496"/>,
</apex:page>
What I need to do is add logic to display the correct image depending on the name of the record so something like:
<apex:page standardController="Carrier__c" >
IF Carrier__c.Name="Safeco", <img src="{!$Resource.SafecoMap}" width="772" height="496"/>,
IF Carrier__c.Name=...
</apex:page>
This way I can display the appropriate image for each carrier record. Does anyone know the correct syntax to accomplish this?
- dburks_goosehead
- May 01, 2012
- Like
- 0
- Continue reading or reply
Simple Trigger To Delete Records
Hi,
I am new to Apex development and looking for some help with a simple trigger to delete erroneous opportunities created by an automated process.
Basically, we want to delete any opportunity that is created where the opportunity name = "..."
Thanks for any assistance!
- PeteM
- March 09, 2012
- Like
- 0
- Continue reading or reply