• Andy Stollmeyer
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hello,

First off, I'm not a developer and have taught myself most of what I know about APEX over the past few years.

I was hoping to upload a .doc file to my SFDC instance and use that .doc file to create a Google Doc that can then be filled out by my users.  The last want is to return the URL of the Google Doc and add to a field on the object from which the user triggers this action (ideally on the Opportunity object, invoked by a button push).

I'm pretty sure I read in the documentation that you can upload an SFDC Document to Google Docs (assuming it's a supported file type), I just can't figure out how to do it.  Does anyone have any sample code or suggestions to get me on the right track?

Many MANY thanks in advance!!
Hi,

I need to convert the below Trigger into an @future, which I have no knowledge of.  I tried to simply add the annotation "@future" but apparently you can't pass sObjects to @future methods.  I am really stuck here, any help is greatly appreciated!

Trigger
//TASK TRIGGER
trigger TaskTrigger on Task (after insert) {
    if(Trigger.isAfter){
        if(Trigger.isInsert){
            TaskTriggerHandler inserter = new TaskTriggerHandler();
            inserter.InsertContactUpdateStatus(Trigger.new);
        }
    }
}
Class:
public with sharing class TaskTriggerHandler {

    public void InsertContactUpdateStatus(List<Task> newList){
        set<Id> ctIds = new set<Id>();
        set<Id> callIds = new set<Id>();
        set<Id> emailIds = new set<Id>();
        for(Task t: newList){
            String whoId = t.WhoId;
            if(whoId!=null && whoId.startsWith('003')){
                ctIds.add(t.WhoId);
                if(t.isClosed == TRUE){
                    if(t.Type != null && t.Type == 'Call'){
                        callIds.add(t.WhoID);
                    }
                    if(t.Type != null && t.Type == 'Email'){
                        emailIds.add(t.WhoID);
                    }
                }
            }
        }
        BUNCH OF ADDITIONAL LOGIC THAT I DONT THINK IS IMPORTANT
    }
}

 
I am working with bootstrap inside of a VF page and am having issues with the way the <apex:inilneEditSupport> component renders within a repeat.  Below is the code snippet:
 
<apex:panelgrid columns="2" >
    <apex:outputlabel >Competitor: &nbsp; </apex:outputlabel>
    <apex:outputField value="{!Opportunity.Competitor__c}" >
            <apex:inlineEditSupport changedStyleClass="changed" showOnEdit="saveButton"  />
    </apex:outputField>
</apex:panelgrid>

<apex:panelgrid columns="2" >
    <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.DiscoveryMilestones}" var="f" >
        <apex:outputlabel >{!f.Label}:</apex:outputlabel>
        <apex:outputField value="{!Opportunity[f]}" >
            <apex:inlineEditSupport changedStyleClass="changed" showOnEdit="saveButton"  />
        </apex:outputField>
    </apex:repeat>
</apex:panelgrid>

And below is a screenshot of how it renders:
User-added image

As you can see it throws a line break into the apex:repeat component for some reason.  Has anyone encountered this before?
I've created a VF page that works great.  However, I cannot get the test class to pass for the life of me.  Below is an exceprt from my VF extension:
public class OpportunityWonExt{
    
    ApexPages.StandardController controller;
    public Opportunity theOpp {get;set;}
    public Account act {get; set;}
    public Contract ct {get; set;}
    
    public OpportunityWonExt(ApexPages.standardController controller){
        theOpp = (Opportunity)controller.getRecord();
        theOpp.CloseDate = Date.today();
        theOpp.StageName = 'Closed Won';
        String actid = theOpp.AccountID;
        OpportunityWonProcess__c settings = OpportunityWonProcess__c.getInstance('Standard Settings');
        String ctOwner = settings.Contract_Owner__c;
        act = [SELECT Id, Name, Company_Size_Type__c FROM Account WHERE ID =:actid ];
        system.debug('LOOK HERE act' + act);
        ct = new Contract();
        ct.AccountID = theOpp.AccountID;
        ct.Status = 'Draft';
        ct.ContractTerm = 12;
        ct.OwnerID = ctOwner;
Below is an excerpt from my test class
 
@isTest(SeeAllData=true) 
private Class OpportunityWonTest{
    
    static testMethod void theTests(){
        // setup some variables 
        String standardPriceBookId = '';
        String UID = '';
        String opportunityName = 'This Is My Favorite Opportunity1234';
        User u = [SELECT ID FROM User WHERE IsActive = TRUE LIMIT 1];
        UID = u.ID;
        
        // Select pricebook
        PriceBook2 pb2Standard = [SELECT ID FROM Pricebook2 WHERE IsStandard = TRUE];
        standardPriceBookId = pb2Standard.Id;
        
        // Setup Account
        Account a = new Account(Name = 'Test Account',Website = 'www.test.com',Company_Size_Type__c = 'Enterprise',OwnerID=UID);
        insert a;
        
        // Setup Opportunity
        Date closedate =  Date.today();
        Opportunity o = new Opportunity(Account = a, Name=opportunityName, StageName='Prospecting', CloseDate=Date.today(),Logo_Use__c = 'Yes', OwnerID=UID);
        insert o;
        Opportunity opp = [Select ID from Opportunity WHERE Name = 'This Is My Favorite Opportunity1234'];
        
        // set up product2
        Product2 p2 = new Product2(Name='Test Product',isActive=true);
        insert p2;
        
        // set up PricebookEntry
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p2.Id, UnitPrice=99, isActive=true);
        insert pbe;
        
        // set up OpportunityLineItem
        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99, Discount__c=0, Contract_Length__c = 12);
        insert oli;

        // load the page       
        PageReference pageRef = Page.OpportunityWon;
        pageRef.getParameters().put('Id',opp.id);
        Test.setCurrentPageReference(pageRef);
        
        // load the extension
        ApexPages.StandardController newcontroller = new ApexPages.StandardController(opp);
       OpportunityWonExt OppWonExt = new OpportunityWonExt(newcontroller);

When I run the test I get the error "System.QueryException: List has no rows for assignment to SObject" pointing to line 15 for the extension class and line 45 for the test class.

The confusing part is the Account is defined, as it saves the Account fields when I save the page.  Additionally, when I debug there is an Account being selected, so no idea how the list is ending up empty...
Hi,

I need to convert the below Trigger into an @future, which I have no knowledge of.  I tried to simply add the annotation "@future" but apparently you can't pass sObjects to @future methods.  I am really stuck here, any help is greatly appreciated!

Trigger
//TASK TRIGGER
trigger TaskTrigger on Task (after insert) {
    if(Trigger.isAfter){
        if(Trigger.isInsert){
            TaskTriggerHandler inserter = new TaskTriggerHandler();
            inserter.InsertContactUpdateStatus(Trigger.new);
        }
    }
}
Class:
public with sharing class TaskTriggerHandler {

    public void InsertContactUpdateStatus(List<Task> newList){
        set<Id> ctIds = new set<Id>();
        set<Id> callIds = new set<Id>();
        set<Id> emailIds = new set<Id>();
        for(Task t: newList){
            String whoId = t.WhoId;
            if(whoId!=null && whoId.startsWith('003')){
                ctIds.add(t.WhoId);
                if(t.isClosed == TRUE){
                    if(t.Type != null && t.Type == 'Call'){
                        callIds.add(t.WhoID);
                    }
                    if(t.Type != null && t.Type == 'Email'){
                        emailIds.add(t.WhoID);
                    }
                }
            }
        }
        BUNCH OF ADDITIONAL LOGIC THAT I DONT THINK IS IMPORTANT
    }
}

 
I've created a VF page that works great.  However, I cannot get the test class to pass for the life of me.  Below is an exceprt from my VF extension:
public class OpportunityWonExt{
    
    ApexPages.StandardController controller;
    public Opportunity theOpp {get;set;}
    public Account act {get; set;}
    public Contract ct {get; set;}
    
    public OpportunityWonExt(ApexPages.standardController controller){
        theOpp = (Opportunity)controller.getRecord();
        theOpp.CloseDate = Date.today();
        theOpp.StageName = 'Closed Won';
        String actid = theOpp.AccountID;
        OpportunityWonProcess__c settings = OpportunityWonProcess__c.getInstance('Standard Settings');
        String ctOwner = settings.Contract_Owner__c;
        act = [SELECT Id, Name, Company_Size_Type__c FROM Account WHERE ID =:actid ];
        system.debug('LOOK HERE act' + act);
        ct = new Contract();
        ct.AccountID = theOpp.AccountID;
        ct.Status = 'Draft';
        ct.ContractTerm = 12;
        ct.OwnerID = ctOwner;
Below is an excerpt from my test class
 
@isTest(SeeAllData=true) 
private Class OpportunityWonTest{
    
    static testMethod void theTests(){
        // setup some variables 
        String standardPriceBookId = '';
        String UID = '';
        String opportunityName = 'This Is My Favorite Opportunity1234';
        User u = [SELECT ID FROM User WHERE IsActive = TRUE LIMIT 1];
        UID = u.ID;
        
        // Select pricebook
        PriceBook2 pb2Standard = [SELECT ID FROM Pricebook2 WHERE IsStandard = TRUE];
        standardPriceBookId = pb2Standard.Id;
        
        // Setup Account
        Account a = new Account(Name = 'Test Account',Website = 'www.test.com',Company_Size_Type__c = 'Enterprise',OwnerID=UID);
        insert a;
        
        // Setup Opportunity
        Date closedate =  Date.today();
        Opportunity o = new Opportunity(Account = a, Name=opportunityName, StageName='Prospecting', CloseDate=Date.today(),Logo_Use__c = 'Yes', OwnerID=UID);
        insert o;
        Opportunity opp = [Select ID from Opportunity WHERE Name = 'This Is My Favorite Opportunity1234'];
        
        // set up product2
        Product2 p2 = new Product2(Name='Test Product',isActive=true);
        insert p2;
        
        // set up PricebookEntry
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p2.Id, UnitPrice=99, isActive=true);
        insert pbe;
        
        // set up OpportunityLineItem
        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99, Discount__c=0, Contract_Length__c = 12);
        insert oli;

        // load the page       
        PageReference pageRef = Page.OpportunityWon;
        pageRef.getParameters().put('Id',opp.id);
        Test.setCurrentPageReference(pageRef);
        
        // load the extension
        ApexPages.StandardController newcontroller = new ApexPages.StandardController(opp);
       OpportunityWonExt OppWonExt = new OpportunityWonExt(newcontroller);

When I run the test I get the error "System.QueryException: List has no rows for assignment to SObject" pointing to line 15 for the extension class and line 45 for the test class.

The confusing part is the Account is defined, as it saves the Account fields when I save the page.  Additionally, when I debug there is an Account being selected, so no idea how the list is ending up empty...