• Julianne Boley
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I am not an advance developer by any definition, and I have been trying to figure this out pouring over other blogs and forums for days now.  I finally give up and am hoping someone can help me.

I have a flow that I am calling and passing variables to via a custom button (Visualforce Page) on the Account detail page.  The page setting the flow finish page and redirecting the user to the record created by the flow by using a controller extension. 

Everything is working as it should, but I won't be able to move any of this to production until I can figure out a way to get test coverage of the controller extension.

This is the class:
public class takeMetoContractController {
public takeMetoContractController(ApexPages.StandardController controller) {
}

public Flow.Interview.Buan_Test rFlow {get; set;}
  

    public String getcontractID() {

        if (rFlow==null) return '';

        else return rFlow.varMcContractID;

    }


    public PageReference getFinishPage(){

        PageReference p = new PageReference('/' + getcontractID() );

        p.setRedirect(true);

        return p;
    }
}

It is being used in this page:
<apex:page sidebar="false"  standardController="Account" extensions="takeMetoContractController">

<flow:interview name="Buan_Test" interview="{!rFlow}" finishLocation="{!FinishPage}">
<apex:param name="Accountsfid" value="{!account.Id}"/>
<apex:param name="AccountSFName" value="{!account.Name}"/>
</flow:interview>
</apex:page>

I've got no idea how to get this test class to actually call the controller extension appropriately, but I have managed to get a test class to save.  Here is what I have (no making fun, please):

@isTest
public class testtakeMetoContractController {

public static void testtakeMetoContractController() {

    //Insert Account
    Account acct = new Account(Name='TestClassAccount');
    insert acct;
  
    // Retrieve the new Account
    acct = [SELECT Id,Name FROM Account WHERE Id =:acct.Id];
  
    //Insert Contact
    Contact c = new Contact (Account=acct, FirstName='Test', LastName='Contact');
    insert c;
  
    //Insert McContract
    McContracts__c mc = new McContracts__c (Account_Name__c=acct.Id, Contact__c=c.Id);
    insert mc;
  
    //Retrieve the new Contract
    mc = [Select Id, Name FROM McContracts__c WHERE Id =:mc.Id];
  
    String mcID = mc.Id;
    System.debug(mcID);

    ApexPages.StandardController sc = new ApexPages.StandardController(acct);
    takeMetoContractController ec = new takeMetoContractController(sc);
  
    PageReference FlowContractPageRef = Page.FlowContract;
    Test.setCurrentPage(FlowContractPageRef);

    string vaMcContractId=mcId;
    ec.getFinishPage();
    ec.getContractId();
  
    System.test.startTest();
    System.debug('ContractId - Add ContractId');
    System.debug('ContractId - Save');
    System.test.stopTest();
    
}
}

It is clearly a mess, and I really have no idea what I am doing, so if anyone has a solution to this or feels like being a good samaritan and wants to help, it would be greatly appreciated.
I am not an advance developer by any definition, and I have been trying to figure this out pouring over other blogs and forums for days now.  I finally give up and am hoping someone can help me.

I have a flow that I am calling and passing variables to via a custom button (Visualforce Page) on the Account detail page.  The page setting the flow finish page and redirecting the user to the record created by the flow by using a controller extension.  

Everything is working as it should, but I won't be able to move any of this to production until I can figure out a way to get test coverage of the controller extension.

This is the class:
public class takeMetoContractController {
public takeMetoContractController(ApexPages.StandardController controller) {
}

public Flow.Interview.Buan_Test rFlow {get; set;} 
   

    public String getcontractID() {

        if (rFlow==null) return '';

        else return rFlow.varMcContractID;

    }


    public PageReference getFinishPage(){

        PageReference p = new PageReference('/' + getcontractID() );

        p.setRedirect(true);

        return p;
    }
}


It is being used in this page:
<apex:page sidebar="false"  standardController="Account" extensions="takeMetoContractController">

<flow:interview name="Buan_Test" interview="{!rFlow}" finishLocation="{!FinishPage}">
<apex:param name="Accountsfid" value="{!account.Id}"/>
<apex:param name="AccountSFName" value="{!account.Name}"/>
</flow:interview>
</apex:page>

 
I've got no idea how to get this test class to actually call the controller extension appropriately, but I have managed to get a test class to save.  Here is what I have (no making fun, please):

@isTest
public class testtakeMetoContractController {

public static void testtakeMetoContractController() {

    //Insert Account
    Account acct = new Account(Name='TestClassAccount');
    insert acct;
   
    // Retrieve the new Account
    acct = [SELECT Id,Name FROM Account WHERE Id =:acct.Id];
   
    //Insert Contact
    Contact c = new Contact (Account=acct, FirstName='Test', LastName='Contact');
    insert c;
   
    //Insert McContract
    McContracts__c mc = new McContracts__c (Account_Name__c=acct.Id, Contact__c=c.Id);
    insert mc;
   
    //Retrieve the new Contract
    mc = [Select Id, Name FROM McContracts__c WHERE Id =:mc.Id];
   
    String mcID = mc.Id;
    System.debug(mcID);

    ApexPages.StandardController sc = new ApexPages.StandardController(acct);
    takeMetoContractController ec = new takeMetoContractController(sc);
   
    PageReference FlowContractPageRef = Page.FlowContract;
    Test.setCurrentPage(FlowContractPageRef);

    string vaMcContractId=mcId;
    ec.getFinishPage();
    ec.getContractId();
   
    System.test.startTest();
    System.debug('ContractId - Add ContractId');
    System.debug('ContractId - Save');
    System.test.stopTest();
     
}
}


It is clearly a mess, and I really have no idea what I am doing, so if anyone has a solution to this or feels like being a good samaritan and wants to help, it would be greatly appreciated.
I am not an advance developer by any definition, and I have been trying to figure this out pouring over other blogs and forums for days now.  I finally give up and am hoping someone can help me.

I have a flow that I am calling and passing variables to via a custom button (Visualforce Page) on the Account detail page.  The page setting the flow finish page and redirecting the user to the record created by the flow by using a controller extension.  

Everything is working as it should, but I won't be able to move any of this to production until I can figure out a way to get test coverage of the controller extension.

This is the class:
public class takeMetoContractController {
public takeMetoContractController(ApexPages.StandardController controller) {
}

public Flow.Interview.Buan_Test rFlow {get; set;} 
   

    public String getcontractID() {

        if (rFlow==null) return '';

        else return rFlow.varMcContractID;

    }


    public PageReference getFinishPage(){

        PageReference p = new PageReference('/' + getcontractID() );

        p.setRedirect(true);

        return p;
    }
}


It is being used in this page:
<apex:page sidebar="false"  standardController="Account" extensions="takeMetoContractController">

<flow:interview name="Buan_Test" interview="{!rFlow}" finishLocation="{!FinishPage}">
<apex:param name="Accountsfid" value="{!account.Id}"/>
<apex:param name="AccountSFName" value="{!account.Name}"/>
</flow:interview>
</apex:page>

 
I've got no idea how to get this test class to actually call the controller extension appropriately, but I have managed to get a test class to save.  Here is what I have (no making fun, please):

@isTest
public class testtakeMetoContractController {

public static void testtakeMetoContractController() {

    //Insert Account
    Account acct = new Account(Name='TestClassAccount');
    insert acct;
   
    // Retrieve the new Account
    acct = [SELECT Id,Name FROM Account WHERE Id =:acct.Id];
   
    //Insert Contact
    Contact c = new Contact (Account=acct, FirstName='Test', LastName='Contact');
    insert c;
   
    //Insert McContract
    McContracts__c mc = new McContracts__c (Account_Name__c=acct.Id, Contact__c=c.Id);
    insert mc;
   
    //Retrieve the new Contract
    mc = [Select Id, Name FROM McContracts__c WHERE Id =:mc.Id];
   
    String mcID = mc.Id;
    System.debug(mcID);

    ApexPages.StandardController sc = new ApexPages.StandardController(acct);
    takeMetoContractController ec = new takeMetoContractController(sc);
   
    PageReference FlowContractPageRef = Page.FlowContract;
    Test.setCurrentPage(FlowContractPageRef);

    string vaMcContractId=mcId;
    ec.getFinishPage();
    ec.getContractId();
   
    System.test.startTest();
    System.debug('ContractId - Add ContractId');
    System.debug('ContractId - Save');
    System.test.stopTest();
     
}
}


It is clearly a mess, and I really have no idea what I am doing, so if anyone has a solution to this or feels like being a good samaritan and wants to help, it would be greatly appreciated.

I am trying to populate a number of task fields in the body of my email template. I am having problems populating the name for the task "Assigned to" and "Name" fields.
 

I have attached the code I have, plus a screen cap of the fields I am trying to reference.

Please help!
Thanks
 

User-added imageUser-added image