• dburks_goosehead
  • NEWBIE
  • 25 Points
  • Member since 2012
  • Director of Information Systems

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Business requirement - We have a bulk upload job that upserts account records daily. Once the account has met a specific criteria an opportunity should be auto generated with the owner from the account team. 

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?
  • January 30, 2015
  • Like
  • 0
I see reference to a reporting and dashboards Trailhead module that I would like to assign to all of our department heads.  However, there is none to be found.  
 1. Why would this not already exist?
 2. Any idea if this is in the works?
Trying to write a test class for this controller extension which allows me to update an opportunity and case from a visualforce page:

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:

User-added image

Any help getting these lines covered is appreciated.

 

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?

I see reference to a reporting and dashboards Trailhead module that I would like to assign to all of our department heads.  However, there is none to be found.  
 1. Why would this not already exist?
 2. Any idea if this is in the works?
Trying to write a test class for this controller extension which allows me to update an opportunity and case from a visualforce page:

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:

User-added image

Any help getting these lines covered is appreciated.

 
Business requirement - We have a bulk upload job that upserts account records daily. Once the account has met a specific criteria an opportunity should be auto generated with the owner from the account team. 

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?
  • January 30, 2015
  • Like
  • 0

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?

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!

  • March 09, 2012
  • Like
  • 0