• Jeff Jobs
  • NEWBIE
  • 190 Points
  • Member since 2012

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

This is the first time I've attempted to create a REST API layer for my Salesforce ORG.  I'm trying to allow my ORG to receive a REST URI and return a list of Builders (which are Accounts).  The error I get when I try to save this code in the SF Developer Console is:  Method does not exist or incorrect signature: getBuilder(String, RestRequest)

Any assistance you could provide would be greatly appreciated!  Code is below:

@RestResource(urlMapping='/v.1/builders/*')
global with sharing class RESTAPI_MYSQL_Builders {
    
    @HttpGet
    global static List<Account> doGet(RestRequest req, RestResponse res) {
        
        String name = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        
        if(name != 'builders') {
            
            return getBuilder(name, req);
        }else {
            
            return getBuilders(req);
        }
    }
    
    private static List<Account> getBuider(String name, RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        
        return Database.query('select ' + qryFields + ' from Account where name = \'' + name + '\'');
    }
    
    private static List<Account> getBuilders(RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        String qryLimit = 'limit 100';
        String qryOrderby = '';
        String qryWhere = '';
        
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        if(req.params.containsKey('limit')) qryLimit = 'limit' + req.params.get('limit');
        if(req.params.containsKey('orderby')) qryOrderby = 'order by' + req.params.get('orderby');
        if(req.params.containsKey('search')) qryWhere = 'where name LIKE \'' + req.params.get('search') + '%\'';
        
        return Database.query('select' + qryFields + ' from Account ' + qryWhere + ' ' + qryOrderby + ' ' + qryLimit);
    }
}
I'm new to Schedulable Apex and Batch Apex.  I was able to write a Test Class for my Batch Apex, but I'm having trouble writing a Test Class for the code below that schedules my Batch Apex:

global class PropertyLedgerScheduledActual implements Schedulable {
   global void execute(SchedulableContext SC) {
      PropertyLedgerBatchActual plb = new PropertyLedgerBatchActual();
      Database.executeBatch(plb);
   }
}

If someone could reply with the best practices of writing a test class for this type of Schedulable Apex, it would be greatly appreciated :)
Hi,

The purpose of this post is to confirm my understanding of Governor Limits.  In the code below, let's assume that someone will use a Data Loader to mass update 200 records.  I'd like to confirm:

1. The 2 SOQL Statements will only be run once for all 200 records (thus using 2 of an available 100)
2. The 2 DML Statements will only be run once for all 200 records (thus using 2 of an available 200 [some say 150, would like to know which])
3. That this code will support data loader updating for up to 200 records at a time via Trigger.new

Thanks in advance for your comments and time :)

Code:

trigger PropertyLedgerBouncedTrigger on Property_Ledger__c (before update) {

    //Variable Declarations
    RecordType actualFee;
    RecordType expectedFee;
    Decimal collectionAmount;
    Date collectionDate;
    String fiscalYear;
    Id opportunity = NULL;
    Id account = NULL;
    List<Property_Ledger__c> toInsert = new List<Property_Ledger__c>();
    List<Property_Fee_Reconciler__c> alsoInsert = new List<Property_Fee_Reconciler__c>();
    
    //Get the Property Ledger RecordType Ids
    actualFee = [SELECT Id FROM RecordType WHERE SObjectType = 'Property_Ledger__c' AND DeveloperName = 'Property_Actual_Fees_Ledger'];        
    expectedFee = [SELECT Id FROM RecordType WHERE SObjectType = 'Property_Ledger__c' AND DeveloperName = 'Property_Expected_Fees_Ledger'];
    
    //Iterate over the records in the trigger
    for(Property_Ledger__c pl1 :Trigger.new) {
        
        //If the Bounced Date Dump field and the Amount Dump field are filled in from the Excel Data Loader...
        if(pl1.Bounced_Date_Dump__c != NULL && pl1.Amount_Dump__c < 0) {
            
            collectionAmount = pl1.Amount_Dump__c;
            
            collectionDate = Date.newInstance(pl1.Bounced_Date_Dump__c.Year(), pl1.Bounced_Date_Dump__c.Month()+1, 25);
            
            //Account for December bounces
            if(pl1.Bounced_Date_Dump__c.Month() == 12) {
                
                collectionDate = Date.newInstance(pl1.Bounced_Date_Dump__c.Year()+1, 1, 25);
            }
            
            //Reset the Bounced Date Dump field
            pl1.Bounced_Date_Dump__c = NULL;
            
            //Set the Fiscal Year
            fiscalYear = String.valueOf(collectionDate.Year());
            
            //Avoid Null Pointer Errors
            if(pl1.Opportunity__c != NULL) {
                
                opportunity = pl1.Opportunity__c;
            }
            
            if(pl1.Account__c != NULL) {
                
                account = pl1.Account__c;
            }
            
            //Begin Amount/Date update logic
            if(collectionDate.Month() == 1) {
                
                pl1.January_Amount__c = 0;
                pl1.January_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 2) {
                
                pl1.February_Amount__c = 0;
                pl1.February_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 3) {
                
                pl1.March_Amount__c = 0;
                pl1.March_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 4) {
                
                pl1.April_Amount__c = 0;
                pl1.April_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 5) {
                
                pl1.May_Amount__c = 0;
                pl1.May_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 6) {
                
                pl1.June_Amount__c = 0;
                pl1.June_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 7) {
                
                pl1.July_Amount__c = 0;
                pl1.July_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 8) {
                
                pl1.August_Amount__c = 0;
                pl1.August_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 9) {
                
                pl1.September_Amount__c = 0;
                pl1.September_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 10) {
                
                pl1.October_Amount__c = 0;
                pl1.October_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 11) {
                
                pl1.November_Amount__c = 0;
                pl1.November_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 12) {
                
                pl1.December_Amount__c = 0;
                pl1.December_Payout_Date__c = NULL;
            }
            
            //Create Fee Records and add to the toInsert List
            Property_Ledger__c actualFeeLedger = new Property_Ledger__c();
            
            actualFeeLedger.RecordTypeId = actualFee.Id;
            actualFeeLedger.Name = 'Actual Property Ledger: Late Rent Fee';
            actualFeeLedger.Property__c = pl1.Property__c;
            actualFeeLedger.Opportunity__c = opportunity;
            actualFeeLedger.Account__c = account;
            actualFeeLedger.Fiscal_Year__c = fiscalYear;
            actualFeeLedger.Description__c = 'Actual Late Fee';
            
            toInsert.add(actualFeeLedger);
            
            Property_Ledger__c expectedFeeLedger = new Property_Ledger__c();
            
            expectedFeeLedger.RecordTypeId = expectedFee.Id;
            expectedFeeLedger.Name = 'Expected Property Ledger: Late Rent Fee';
            expectedFeeLedger.Property__c = pl1.Property__c;
            expectedFeeLedger.Opportunity__c = opportunity;
            expectedFeeLedger.Account__c = account;
            expectedFeeLedger.Fiscal_Year__c = fiscalYear;
            expectedFeeLedger.Fee_Amount__c = 50.00;
            expectedFeeLedger.Collection_Date__c = collectionDate;
            expectedFeeLedger.Description__c = 'Expected Late Rent Fee';
            
            toInsert.add(expectedFeeLedger);
            
            Property_Fee_Reconciler__c feesReconciler = new Property_Fee_Reconciler__c();
            
            feesReconciler.Expected_Fee__c = expectedFeeLedger.Id;
            feesReconciler.Actual_Fee__c = actualFeeLedger.Id;
            
            alsoInsert.add(feesReconciler);
            
            Property_Ledger__c actualLateRentLedger = new Property_Ledger__c();
            
            actualLateRentLedger.RecordTypeId = actualFee.Id;
            actualLateRentLedger.Name = 'Actual Property Ledger: Delinquent Rent';
            actualLateRentLedger.Property__c = pl1.Property__c;
            actualLateRentLedger.Opportunity__c = opportunity;
            actualLateRentLedger.Account__c = account;
            actualLateRentLedger.Fiscal_Year__c = fiscalYear;
            actualLateRentLedger.Description__c = 'Actual Delinquent Rent Collected';
            
            toInsert.add(actualLateRentLedger);
            
            Property_Ledger__c expectedLateRentLedger = new Property_Ledger__c();
            
            expectedLateRentLedger.RecordTypeId = expectedFee.Id;
            expectedLateRentLedger.Name = 'Expected Property Ledger: Delinquent Rent';
            expectedLateRentLedger.Property__c = pl1.Property__c;
            expectedLateRentLedger.Opportunity__c = opportunity;
            expectedLateRentLedger.Account__c = account;
            expectedLateRentLedger.Fiscal_Year__c = fiscalYear;
            expectedLateRentLedger.Fee_Amount__c = collectionAmount;
            expectedLateRentLedger.Collection_Date__c = collectionDate;
            expectedLateRentLedger.Description__c = 'Expected Delinquent Rent Collected';
            
            toInsert.add(expectedLateRentLedger);
            
            Property_Fee_Reconciler__c rentReconciler = new Property_Fee_Reconciler__c();
            
            rentReconciler.Expected_Fee__c = expectedLateRentLedger.Id;
            rentReconciler.Actual_Fee__c = actualLateRentLedger.Id;
            
            alsoInsert.add(rentReconciler);
        }
    }
    
    //If there are records in the toInsert List, insert them and the alsoInsert List into the database
    if(toInsert.size() > 0) {
        
        insert toInsert;
        insert alsoInsert;
    }
}
Hi,
I'm trying to create some Date Logic in an Apex Class.  Everything I do works exactly how I want, but I can't get coverage on part of the code no matter what I try.  I've included a screenshot:
User-added image
Essentially I'm trying to create two date variables "nextPayDay" and "nextClosingPayDay" based on date fields that are found on my payout object (p).  I include a scenario in my test class where the month + 1 ends up being January (1) and when I do a system.assertEquals, I can see that the year has gone up by 1.  However, it is still red in the test class.  Any help would be greatly appreciated!
 
Hi,

I'm looking for a solution where the end-user logs into Salesforce and, upon login, another browser tab opens to an external website (example: cnn.com).  If it was just me, I would set my browser to launch specific tabs on startup, but I'm trying to set this up for about 90 people (not many are computer saavy) in my ORG and my superior is wondering if I could automate this when they login to Salesforce. 

Any help, or alternative solutions, would be greatly appreciated.  Thanks!
Goal is to enter info on an object, then enter different info on another object by creating multiple records.  So we have an update and multiple inserts.

I'm using buttons to go from from one page to the next and then I'd like a "Make Another" button to simply duplicate the second piece ad infinitum.  Here is what I have so far:

<apex:page standardController="SODA__c" extensions="PutbackExtension">
 
  <apex:sectionHeader title="Create Putback Work - Update SODA"/>
 
  <apex:form >
    <apex:pageBlock >
     
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandButton action="{!save}" value="DONE"/>
        <apex:commandButton action="{!ToRST}" value="Create Resident Service Ticket"/>
      </apex:pageBlockButtons>
     
      <apex:pageBlockSection title="Enter Standard Putback Activity Amounts (If Applicable)" columns="1" collapsible="false">
        <apex:inputField value="{!SODA__c.House_Cleaning_Fee__c}" label="House Cleaning Fee"/>
        <apex:inputField value="{!SODA__c.Carpet_Cleaning_Fee__c}" label="Carpet Cleaning Fee"/>
        <apex:inputField value="{!SODA__c.Painting_Patching_Fee__c}" label="Painting/Patching Fee"/>
      </apex:pageBlockSection>
     
      <apex:pageBlockSection title="Enter Other Putback Activities and Amounts" columns="2" collapsible="false">
        <apex:inputField value="{!SODA__c.Other_Fee_1_Description_Long__c}" label="Other 1 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_1__c}" label="Other 1 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_2_Description_Long__c}" label="Other 2 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_2__c}" label="Other 2 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_3_Description_Long__c}" label="Other 3 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_3__c}" label="Other 3 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_4_Description_Long__c}" label="Other 4 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_4__c}" label="Other 4 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_5_Description_Long__c}" label="Other 5 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_5__c}" label="Other 5 Fee"/>
      </apex:pageBlockSection>
     
    </apex:pageBlock> 
  </apex:form>
</apex:page>


(Second VF Page)
<apex:page standardController="Resident_Service_Tickets__c" extensions="PutbackExtension">
  <apex:sectionHeader title="Create Putback Work - New Resident Service Ticket"/>
  <apex:form >
    <apex:pageBlock >
   
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton immediate="true" action="{!CancelRST}" value="Cancel"/>
        <apex:commandButton action="{!ToRST}" value="Make Another"/>
        <apex:commandButton action="{!save}" value="DONE"/>       
      </apex:pageBlockButtons>
     
      <apex:pageBlockSection title="Enter Putback Service Information" columns="1" collapsible="false">
        <apex:inputField value="{!Resident_Service_Tickets__c.Winning_Trade__c}" label="Trade" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Method_of_Payment_for_Trade__c}" label="Method of Payment" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Amount_Billed_to_MH__c}" label="Billing Amount" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Notes__c}" label="Work Done" required="true"/>
      </apex:pageBlockSection>
     
      <apex:pageBlockSection title="Object Relationships" columns="1" id="section1">
        <!-- <script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]); </script> -->
        <apex:inputField value="{!Resident_Service_Tickets__c.Concierge__c}" label="Concierge"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Resident_Account__c}" label="Resident Account"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Resident_Opportunity__c}" label="Resident Opportunity"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Property__c}" label="Property"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Owner_Account__c}" label="Owner Account"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.SODA__c}" label="SODA"/>
      </apex:pageBlockSection>
   
    </apex:pageBlock>
  </apex:form>
</apex:page>


(Extension Class)
public class PutbackExtension {

    //Declare Instance Variables
    private ApexPages.StandardController sc;
    private Id soda;
    private Id con;
    private Id roppId;
    private Opportunity ropp;
    private Id racc;
    private Id propId;
    private Property__c prop;
    private String putback;
    private Id acc;
   
    //Create Constructor
    public PutbackExtension(ApexPages.StandardController standardController) {
   
        sc = standardController;
       
        if(ApexPages.currentPage().getParameters().get('soda') == '123') {
       
            soda = ApexPages.currentPage().getParameters().get('id');
        }
       
        if(ApexPages.currentPage().getParameters().get('soda') != '123') {
       
            soda = ApexPages.currentPage().getParameters().get('soda');
        }   
       
        roppId = ApexPages.currentPage().getParameters().get('ropp');
        ropp = [SELECT Id, AccountId FROM Opportunity WHERE Id = :roppId];
        racc = ropp.AccountId;
        propId = ApexPages.currentPage().getParameters().get('prop');
        prop = [SELECT Id, Home_Sale_Opportunity__c, Concierge__c FROM Property__c WHERE Id = :propId];
        con = prop.Concierge__c;
        putback = 'PUTBACK';
        Opportunity opp =[SELECT Id, AccountId FROM Opportunity WHERE Id = :prop.Home_Sale_Opportunity__c];
        acc = opp.AccountId;
    }
   
    //Methods
    public PageReference ToRST() {
   
        sc.Save();
       
        Resident_Service_Tickets__c rstRecord = new Resident_Service_Tickets__c();
        rstRecord.Concierge__c = con;
        rstRecord.Resident_Account__c = racc;
        rstRecord.Resident_Opportunity__c = roppId;
        rstRecord.Owner_Account__c = acc;
        rstRecord.Property__c = propId;
        rstRecord.Troubleshooting_Notes__c = putback;
        rstRecord.SODA__c = soda;
        insert rstRecord;
       
        //rstRecord = (Resident_Service_Tickets__c)sc.getRecord();
       
        String soda = ApexPages.currentPage().getParameters().get('id');
        String ropp = ApexPages.currentPage().getParameters().get('ropp');
        String prop = ApexPages.currentPage().getParameters().get('prop');
        String con = ApexPages.currentPage().getParameters().get('con');
               
        PageReference rst = new PageReference('/apex/PutbackPage2?id='+rstRecord.Id+'&soda='+soda+'&ropp='+ropp+'&prop='+prop+'&con='+con+'&rst='+rstRecord.Id);
       
        return rst;
    }      
   
    public PageReference CancelRST() {
   
        String rst = ApexPages.currentPage().getParameters().get('rst');
       
        String soda = ApexPages.currentPage().getParameters().get('soda');
       
        delete [SELECT Id FROM Resident_Service_Tickets__c WHERE Id = :rst];
       
        PageReference start = new PageReference('/'+soda);
       
        return start;
    }
}

It works but when I go to make another Resident Service Ticket (when I push "Make Another") it still shows me the last one filled in as displayed below:

User-added image

I'm know I'm probably missing something with refreshing the standard controller but I'm really at a loss here.  Any help would be greatly apprecitated.  Thanks!

Hi,

 

New to VF so pardon the ignorance.

 

Let's begin with the objective:

 

I decide which Opportunities need to be edited based on specific criteria.  Then I want users to enter in deal numbers and update all the opportunities on the screens.  

 

Here is the code I have:

 

VF:

 

<apex:page controller="listDealNumbers">
<apex:form >
<apex:pageBlock title="Assign Deal Numbers">
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!assign}" value="Assign"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column headerValue="Opportunity">
<apex:outputLink value="https://cs9.salesforce.com/{!opp.Id}" target="_blank">{!Opp.Name}</apex:outputlink>
</apex:column>
<apex:column headerValue="Cha-Ching Date">
<apex:outputField value="{!opp.Cha_Ching_Date_v2__c}"/>
</apex:column>
<apex:column headerValue="Deal Number This Month">
<apex:inputField value="{!opp.Deal_Number_This_Month__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

APEX:

 

public class listDealNumbers {

public List<Opportunity> getOpportunities() {

date myDate = date.Today();
date startOfMonth = myDate.toStartOfMonth();
date startOfLastMonth = startOfMonth.addMonths(-1);
id userId = UserInfo.getUserId();

return [SELECT o.Id, o.Owner.Id, o.Name, o.Cha_Ching_Date_V2__c, o.Deal_Number_This_Month__c FROM Opportunity o
WHERE o.Cha_Ching_Date_V2__c >= :startOfLastMonth AND o.Cha_Ching_Date_V2__c < :startOfMonth AND o.Owner.Id = :userId
ORDER BY o.Cha_Ching_Date_V2__c];
}


public PageReference assign() {
return null;
}

}

 

So everything works but I'm not sure how to use the "assign" method to update the Opportunity Records.  I'd like to just say "update opportunities" but that won't work.  So please help with the missing "update" code I need in the "assign" method.  Thanks so much for any help :)

Hi,

 

I'm writing a test class where I'm testing a "before update" scenario.  

 

Original Class is:

 

public class paymentRecordHandlerRentIn{

//Create a method for GTM Deals
public static void rentIn (Payment_Record__c[] paymentRecords) {

for (Payment_Record__c pr: paymentRecords) {

//Declare Variables
Date month1Date = pr.Move_In_Date__c;
Date month2Date = (((pr.Move_In_Date__c.toStartOfMonth()).addMonths(1)).addDays(24));
Date month3Date = month2Date.addMonths(1);
Date month4Date = month3Date.addMonths(1);
Date month5Date = month4Date.addMonths(1);
Date month6Date = month5Date.addMonths(1);
Date month7Date = month6Date.addMonths(1);
Date month8Date = month7Date.addMonths(1);
Date month9Date = month8Date.addMonths(1);
Date month10Date = month9Date.addMonths(1);
Date month11Date = month10Date.addMonths(1);
Date month12Date = month11Date.addMonths(1);
Date month13Date = month12Date.addMonths(1);
Date month14Date = month13Date.addMonths(1);
Date month15Date = month14Date.addMonths(1);
Date month16Date = month15Date.addMonths(1);
Date month17Date = month16Date.addMonths(1);
Date month18Date = month17Date.addMonths(1);
Date month19Date = month18Date.addMonths(1);
Date month20Date = month19Date.addMonths(1);
Date month21Date = month20Date.addMonths(1);
Date month22Date = month21Date.addMonths(1);
Date month23Date = month22Date.addMonths(1);
Date month24Date = month23Date.addMonths(1);
Date month25Date = month24Date.addMonths(1);
Date month26Date = month25Date.addMonths(1);
Date month27Date = month26Date.addMonths(1);
Date month28Date = month27Date.addMonths(1);
Date month29Date = month28Date.addMonths(1);
Date month30Date = month29Date.addMonths(1);
Date month31Date = month30Date.addMonths(1);
Date month32Date = month31Date.addMonths(1);
Date month33Date = month32Date.addMonths(1);
Date month34Date = month33Date.addMonths(1);
Date month35Date = month34Date.addMonths(1);
Date month36Date = month35Date.addMonths(1);
Date month37Date = month36Date.addMonths(1);
Date month38Date = month37Date.addMonths(1);
Date month39Date = month38Date.addMonths(1);
Date month40Date = month39Date.addMonths(1);
Date month41Date = month40Date.addMonths(1);
Date month42Date = month41Date.addMonths(1);
Date month43Date = month42Date.addMonths(1);
Date month44Date = month43Date.addMonths(1);
Date month45Date = month44Date.addMonths(1);
Date month46Date = month45Date.addMonths(1);
Date month47Date = month46Date.addMonths(1);
Date month48Date = month47Date.addMonths(1);
Date month49Date = month48Date.addMonths(1);
Date month50Date = month49Date.addMonths(1);
Date month51Date = month50Date.addMonths(1);
Date month52Date = month51Date.addMonths(1);
Date month53Date = month52Date.addMonths(1);
Date month54Date = month53Date.addMonths(1);
Date month55Date = month54Date.addMonths(1);
Date month56Date = month55Date.addMonths(1);
Date month57Date = month56Date.addMonths(1);
Date month58Date = month57Date.addMonths(1);
Date month59Date = month58Date.addMonths(1);
Date month60Date = month59Date.addMonths(1);
Date finalPaymentDate = month60Date.addMonths(1);

Decimal fPRP = pr.Prorated_Rent_Amount__c;
Decimal rFR1 = pr.Rent_from_Resident_Year_One__c;
Decimal rFR2 = pr.Rent_from_Resident_Year_Two__c;
Decimal rFR3 = pr.Rent_from_Resident_Year_Three__c;
Decimal rFR4 = pr.Rent_from_Resident_Year_Four__c;
Decimal rFR5 = pr.Rent_from_Resident_Year_Five__c;

//Standard Rent Agreement
if(pr.RecordTypeId == '012J00000000MgB') {

//Print "No Matter What" fields
pr.Month_1_Payment_Date__c = month1Date;
pr.Month_2_Payment_Amount__c = rFR1;
pr.Month_2_Payment_Date__c = month2Date;
pr.Month_3_Payment_Amount__c = rFR1;
pr.Month_3_Payment_Date__c = month3Date;
pr.Month_4_Payment_Amount__c = rFR1;
pr.Month_4_Payment_Date__c = month4Date;
pr.Month_5_Payment_Amount__c = rFR1;
pr.Month_5_Payment_Date__c = month5Date;
pr.Month_6_Payment_Amount__c = rFR1;
pr.Month_6_Payment_Date__c = month6Date;
pr.Month_7_Payment_Amount__c = rFR1;
pr.Month_7_Payment_Date__c = month7Date;
pr.Month_8_Payment_Amount__c = rFR1;
pr.Month_8_Payment_Date__c = month8Date;
pr.Month_9_Payment_Amount__c = rFR1;
pr.Month_9_Payment_Date__c = month9Date;
pr.Month_10_Payment_Amount__c = rFR1;
pr.Month_10_Payment_Date__c = month10Date;
pr.Month_11_Payment_Amount__c = rFR1;
pr.Month_11_Payment_Date__c = month11Date;
pr.Month_12_Payment_Amount__c = rFR1;
pr.Month_12_Payment_Date__c = month12Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Month_1_Payment_Type__c = 'First Prorated Rent Amount';
pr.Month_1_Payment_Amount__c = fPRP;
pr.Final_Payment_Amount__c = rFR1;
pr.Final_Payment_Date__c = finalPaymentDate;

//No Prorated Rent
}Else if (pr.Override_Prorated_Rent__c == TRUE) {

pr.Month_1_Payment_Type__c = 'Standard Rent Payment';
pr.Month_1_Payment_Amount__c = rFR1;
}

//Begin Multi-Year Logic

//Year One
}Else if(pr.RecordTypeId == '012J00000000LyZ') {

//Print "No Matter What" fields
pr.Month_1_Payment_Date__c = month1Date;
pr.Month_2_Payment_Amount__c = rFR1;
pr.Month_2_Payment_Date__c = month2Date;
pr.Month_3_Payment_Amount__c = rFR1;
pr.Month_3_Payment_Date__c = month3Date;
pr.Month_4_Payment_Amount__c = rFR1;
pr.Month_4_Payment_Date__c = month4Date;
pr.Month_5_Payment_Amount__c = rFR1;
pr.Month_5_Payment_Date__c = month5Date;
pr.Month_6_Payment_Amount__c = rFR1;
pr.Month_6_Payment_Date__c = month6Date;
pr.Month_7_Payment_Amount__c = rFR1;
pr.Month_7_Payment_Date__c = month7Date;
pr.Month_8_Payment_Amount__c = rFR1;
pr.Month_8_Payment_Date__c = month8Date;
pr.Month_9_Payment_Amount__c = rFR1;
pr.Month_9_Payment_Date__c = month9Date;
pr.Month_10_Payment_Amount__c = rFR1;
pr.Month_10_Payment_Date__c = month10Date;
pr.Month_11_Payment_Amount__c = rFR1;
pr.Month_11_Payment_Date__c = month11Date;
pr.Month_12_Payment_Amount__c = rFR1;
pr.Month_12_Payment_Date__c = month12Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Month_1_Payment_Type__c = 'First Prorated Rent Amount';
pr.Month_1_Payment_Amount__c = fPRP;

//No Prorated Rent
}Else if (pr.Override_Prorated_Rent__c == TRUE) {

pr.Month_1_Payment_Type__c = 'Standard Rent Payment';
pr.Month_1_Payment_Amount__c = rFR1;
}

//Year Two
}Else if (pr.RecordTypeId == '012J00000000MgG') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR2;
pr.Month_1_Payment_Date__c = month13Date;
pr.Month_2_Payment_Amount__c = rFR2;
pr.Month_2_Payment_Date__c = month14Date;
pr.Month_3_Payment_Amount__c = rFR2;
pr.Month_3_Payment_Date__c = month15Date;
pr.Month_4_Payment_Amount__c = rFR2;
pr.Month_4_Payment_Date__c = month16Date;
pr.Month_5_Payment_Amount__c = rFR2;
pr.Month_5_Payment_Date__c = month17Date;
pr.Month_6_Payment_Amount__c = rFR2;
pr.Month_6_Payment_Date__c = month18Date;
pr.Month_7_Payment_Amount__c = rFR2;
pr.Month_7_Payment_Date__c = month19Date;
pr.Month_8_Payment_Amount__c = rFR2;
pr.Month_8_Payment_Date__c = month20Date;
pr.Month_9_Payment_Amount__c = rFR2;
pr.Month_9_Payment_Date__c = month21Date;
pr.Month_10_Payment_Amount__c = rFR2;
pr.Month_10_Payment_Date__c = month22Date;
pr.Month_11_Payment_Amount__c = rFR2;
pr.Month_11_Payment_Date__c = month23Date;
pr.Month_12_Payment_Amount__c = rFR2;
pr.Month_12_Payment_Date__c = month24Date;
pr.Stop_Code__c = TRUE;

//Year Three
}Else if (pr.RecordTypeId == '012J00000000MgL') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR3;
pr.Month_1_Payment_Date__c = month25Date;
pr.Month_2_Payment_Amount__c = rFR3;
pr.Month_2_Payment_Date__c = month26Date;
pr.Month_3_Payment_Amount__c = rFR3;
pr.Month_3_Payment_Date__c = month27Date;
pr.Month_4_Payment_Amount__c = rFR3;
pr.Month_4_Payment_Date__c = month28Date;
pr.Month_5_Payment_Amount__c = rFR3;
pr.Month_5_Payment_Date__c = month29Date;
pr.Month_6_Payment_Amount__c = rFR3;
pr.Month_6_Payment_Date__c = month30Date;
pr.Month_7_Payment_Amount__c = rFR3;
pr.Month_7_Payment_Date__c = month31Date;
pr.Month_8_Payment_Amount__c = rFR3;
pr.Month_8_Payment_Date__c = month32Date;
pr.Month_9_Payment_Amount__c = rFR3;
pr.Month_9_Payment_Date__c = month33Date;
pr.Month_10_Payment_Amount__c = rFR3;
pr.Month_10_Payment_Date__c = month34Date;
pr.Month_11_Payment_Amount__c = rFR3;
pr.Month_11_Payment_Date__c = month35Date;
pr.Month_12_Payment_Amount__c = rFR3;
pr.Month_12_Payment_Date__c = month36Date;
pr.Stop_Code__c = TRUE;

//Year Four
}Else if (pr.RecordTypeId == '012J00000000MgQ') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR4;
pr.Month_1_Payment_Date__c = month37Date;
pr.Month_2_Payment_Amount__c = rFR4;
pr.Month_2_Payment_Date__c = month38Date;
pr.Month_3_Payment_Amount__c = rFR4;
pr.Month_3_Payment_Date__c = month39Date;
pr.Month_4_Payment_Amount__c = rFR4;
pr.Month_4_Payment_Date__c = month40Date;
pr.Month_5_Payment_Amount__c = rFR4;
pr.Month_5_Payment_Date__c = month41Date;
pr.Month_6_Payment_Amount__c = rFR4;
pr.Month_6_Payment_Date__c = month42Date;
pr.Month_7_Payment_Amount__c = rFR4;
pr.Month_7_Payment_Date__c = month43Date;
pr.Month_8_Payment_Amount__c = rFR4;
pr.Month_8_Payment_Date__c = month44Date;
pr.Month_9_Payment_Amount__c = rFR4;
pr.Month_9_Payment_Date__c = month45Date;
pr.Month_10_Payment_Amount__c = rFR4;
pr.Month_10_Payment_Date__c = month46Date;
pr.Month_11_Payment_Amount__c = rFR4;
pr.Month_11_Payment_Date__c = month47Date;
pr.Month_12_Payment_Amount__c = rFR4;
pr.Month_12_Payment_Date__c = month48Date;
pr.Stop_Code__c = TRUE;

//Year Five
}Else if (pr.RecordTypeId == '012J00000000MgH') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR5;
pr.Month_1_Payment_Date__c = month49Date;
pr.Month_2_Payment_Amount__c = rFR5;
pr.Month_2_Payment_Date__c = month50Date;
pr.Month_3_Payment_Amount__c = rFR5;
pr.Month_3_Payment_Date__c = month51Date;
pr.Month_4_Payment_Amount__c = rFR5;
pr.Month_4_Payment_Date__c = month52Date;
pr.Month_5_Payment_Amount__c = rFR5;
pr.Month_5_Payment_Date__c = month53Date;
pr.Month_6_Payment_Amount__c = rFR5;
pr.Month_6_Payment_Date__c = month54Date;
pr.Month_7_Payment_Amount__c = rFR5;
pr.Month_7_Payment_Date__c = month55Date;
pr.Month_8_Payment_Amount__c = rFR5;
pr.Month_8_Payment_Date__c = month56Date;
pr.Month_9_Payment_Amount__c = rFR5;
pr.Month_9_Payment_Date__c = month57Date;
pr.Month_10_Payment_Amount__c = rFR5;
pr.Month_10_Payment_Date__c = month58Date;
pr.Month_11_Payment_Amount__c = rFR5;
pr.Month_11_Payment_Date__c = month59Date;
pr.Month_12_Payment_Amount__c = rFR5;
pr.Month_12_Payment_Date__c = month60Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Final_Payment_Amount__c = rFR5;
pr.Final_Payment_Date__c = finalPaymentDate;
}
}

}

}

}

 

Test Class is:

 

@isTest

 

public class paymentRecordsTestRentIn{

static testMethod void standardTest() {

//Create Fake Records
RecordType rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Account' AND isActive = true AND DeveloperName like '%Person_Account%' LIMIT 1];
Account a = new Account();
a.RecordTypeId = rt.Id;
a.LastName = 'test';
insert a;

Property__c prop = new Property__c();
prop.Address_Line_1__c = '123 Street';
prop.Name = '123 Street';
insert prop;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity oppR1 = new Opportunity();
oppR1.AccountId = a.Id;
oppR1.Name = 'test';
oppR1.StageName = 'test';
oppR1.CloseDate = system.today();
oppR1.RecordTypeId = rt.Id;
oppR1.Property__c = prop.Id;
oppR1.Move_In_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_End_Date__c = date.parse('05/17/2014');
oppR1.Days_of_the_Month__c = 31;
oppR1.Rent_From_Resident__c = 1000;
insert oppR1;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity oppR2 = new Opportunity();
oppR2.AccountId = a.Id;
oppR2.Name = 'test';
oppR2.StageName = 'test';
oppR2.CloseDate = system.today();
oppR2.RecordTypeId = rt.Id;
oppR2.Property__c = prop.Id;
oppR1.Move_In_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_End_Date__c = date.parse('05/17/2014');
oppR2.Days_of_the_Month__c = 31;
oppR2.Rent_From_Resident__c = 1000;
oppR2.Rent_From_Resident_Year_2__c = 1050;
oppR2.Rent_From_Resident_Year_3__c = 1100;
oppR2.Rent_From_Resident_Year4__c = 1150;
oppR2.Rent_From_Resident_Year_5__c = 1200;
insert oppR2;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Payment_Record__c' AND isActive = true AND DeveloperName like '%Rent_In%' LIMIT 1];
Payment_Record__c prHS1 = new Payment_Record__c();
prHS1.RecordTypeId = rt.Id;
prHS1.Opportunity__c = oppR1.id;
prHS1.Property__c = prop.id;
insert prHS1;

 

//Begin Testing

Test.startTest();

prHS1.Override_Prorated_Rent__c = FALSE;
update prHS1;

prHS1 = [Select id, Month_1_Payment_Type__c, Month_1_Payment_Amount__c, Month_1_Payment_Date__c,
Month_2_Payment_Amount__c, Month_2_Payment_Date__c, Final_Payment_Amount__c, Final_Payment_Date__c, Move_In_Date__c,
Stop_Code__c, Override_Prorated_Rent__c
From Payment_Record__c Where Id = :prHS1.id];

//Standard Rent with Prorated Rent Test
system.assert(prHS1.Month_1_Payment_Type__c == 'First Prorated Rent Amount'); //Line 69
system.assert(prHS1.Month_1_Payment_Amount__c == 483.87);
system.assert(prHS1.Month_1_Payment_Date__c == prHS1.Move_In_Date__c);
system.assert(prHS1.Month_2_Payment_Amount__c == 1000);
system.assert(prHS1.Month_2_Payment_Date__c == (((prHS1.Move_In_Date__c.toStartOfMonth()).addMonths(1)).addDays(24)));
system.assert(prHS1.Stop_Code__c == TRUE);

Test.stopTest();
}

}

 

Error Message is:

 

Assertion Failed at Line 69

 

I've marked Line 69 in comment code

 

What's happening is that even though I'm typing "update prHS1" no update is taking place.  Thus, the field at line 69 is null and passes if I type "== null" instead of my string.  I should mention that the original class code works when put into practice, and that no errors are provided in the developer console.  Obviously, I'm missing a huge piece for "before update" test classes (this is my first one).  

 

Any help would be appreciated.  Under a tight deadline, so would appreciate any thoughts sooner rather than later.  Thanks!

Hi all,

 

Still new to Apex and am having trouble with this test class:

 

@isTest

public class emailHandlerTest {

static testMethod void emailTest() {

//Create fake records
RecordType rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Account' AND isActive = true AND DeveloperName like '%Person_Account%' LIMIT 1];
Account a = new Account();
a.RecordTypeId = rt.Id;
a.LastName = 'test';
insert a;

Property__c prop = new Property__c();
prop.Address_Line_1__c = '123 Street';
prop.Name = '123 Street';
insert prop;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity opp = new Opportunity();
opp.AccountId = a.Id;
opp.Name = 'test';
opp.StageName = 'test';
opp.CloseDate = system.today();
opp.RecordTypeId = rt.Id;
opp.Property__c = prop.Id;
insert opp;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Applicants__c' AND isActive = true AND Name like '%Primary_Applicant%' LIMIT 1];
Applicants__c app = new Applicants__c();
app.RecordTypeId = rt.Id;
app.Opportunity_Name__c = opp.Id;
app.Property__c = prop.Id;
app.Applicant_Email__c = 'test@test.com';

//Initiate Test One - Will the first email field fill in after an applicant record is inserted?
Test.startTest();

insert app;

Test.stopTest();

system.assert(opp.Additional_Applicant_1__c == 'test@test.com'); //This is Line 43
}
}

 

Actual Trigger being tested is here:

 

trigger emailHandler on Applicants__c (after insert) {

Set<ID> opportunityIds = new Set<ID>();

for (Applicants__c a: trigger.new) {

opportunityIds.add(a.Opportunity_Name__c);
}

List<Applicants__c> applicantEmail = [Select id, Applicant_Email__c From Applicants__c Where id in: Trigger.new];

List<Opportunity> emailFields = [Select id, Additional_Applicant_1__c, Additional_Applicant_2__c,Additional_Applicant_3__c,Additional_Applicant_4__c
From Opportunity
Where id in: opportunityIds];

for (Opportunity o: emailFields) {

for (Applicants__c a: applicantEmail) {

String email = a.Applicant_Email__c;

if (o.Additional_Applicant_1__c == null) {

o.Additional_Applicant_1__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c == null) {

o.Additional_Applicant_2__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c == null) {

o.Additional_Applicant_3__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c <> null && o.Additional_Applicant_4__c == null) {

o.Additional_Applicant_4__c = email;
}
}
}

update emailFields;
}

 

As you can see I'm creating fake records so that I can fulfill the required fields on my Applicant__c object.  I have to have an account to create the property, a property to create the opportunity, etc.  

 

The trigger I'm testing is "after insert" so that's why I'm putting the "insert app" line in within the test; because I want to see what happens to the opportunity after an applicant record is inserted.  What should happen is that "test@test.com" gets put in an opportunity field called "Additional_Applicant_1__c".

 

I'm using the Developer Console and there are no errors to solve.  I run the test and get "Assertion Failed" at line 43, which I take to mean that "test@test.com" is NOT present on that field.

 

The trouble is that an actual test of this code works perfectly (meaning if I physically create the applicant record instead of using the test class).

 

Bottom Line: I know the code works, but I can't get the test class to prove it.  Please help!

 

Hi Everyone,

 

I'm very new to Apex so please forgive a few noob errors.  

 

I'm using Apex for date logic, something FLOW falls short on.  The following Trigger works "before update" in tandem with my FLOW.  So the FLOW creates a record, then "updates" it which instantiates the Trigger.   The problem is, all of the FLOW stuff works, and NONE of the Apex stuff works and there is NOT an error message.  The dates I want from Apex just don't show up.  I've also tried manually creating the the record (no FLOW) with the exact same date results.  Please help.  I know I'm missing something :)

 

trigger RentOutPaymentRecordDateLogic on Payment_Record__c (before update) {

//Create Payment Record Collection
List<Payment_Record__c> RentOutPaymentRecords =
[Select j.RecordTypeId, j.First_Payment_Date__c, j.Waiver_Period_In_Days__c, j.Payout_Day__c, j.Override_Prorated_Rent__c
From Payment_Record__c j
Where j.RecordTypeId = '012d0000000wnuF'
And Payment_Record__c.id IN: Trigger.new
For Update];

//Iterate through Payment Records
for (Payment_Record__c pr: RentOutPaymentRecords) {
RentOutPaymentRecordCreation.dateUpdates(RentOutPaymentRecords);
}
}

 

public class RentOutPaymentRecordCreation{

public static void dateUpdates (Payment_Record__c[] RentOutPaymentRecords) {

for (Payment_Record__c pr: RentOutPaymentRecords) {

//Declare Date Variables
Date month3Date7 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(6));
Date month3Date10 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(9));
Date month4DatePlain7 = month3Date7.addMonths(1);
Date month4DatePlain10 = month3Date10.addMonths(1);
Date month4Date7 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(6));
Date month4Date10 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(9));
Date month5Date7 = month4Date7.addMonths(1);
Date month5Date10 = month4Date10.addMonths(1);
Date month6Date7 = month5Date7.addMonths(1);
Date month6Date10 = month5Date10.addMonths(1);
Date month7Date7 = month6Date7.addMonths(1);
Date month7Date10 = month6Date10.addMonths(1);
Date month8Date7 = month7Date7.addMonths(1);
Date month8Date10 = month7Date10.addMonths(1);
Date month9Date7 = month8Date7.addMonths(1);
Date month9Date10 = month8Date10.addMonths(1);
Date month10Date7 = month9Date7.addMonths(1);
Date month10Date10 = month9Date10.addMonths(1);
Date month11Date7 = month10Date7.addMonths(1);
Date month11Date10 = month10Date10.addMonths(1);
Date month12Date7 = month11Date7.addMonths(1);
Date month12Date10 = month11Date10.addMonths(1);
Date finalPaymentDate7 = month12Date7.addMonths(1);
Date finalPaymentDate10 = month12Date10.addMonths(1);

if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 10th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;
pr.Final_Payment_Date__c = finalPaymentDate10;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 7th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
pr.Final_Payment_Date__c = finalPaymentDate7;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 10th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 7th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 10th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date10;
pr.Month_4_Payment_Date__c = month4DatePlain10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;
pr.Final_Payment_Date__c = finalPaymentDate10;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 7th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date7;
pr.Month_4_Payment_Date__c = month4DatePlain7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
pr.Final_Payment_Date__c = finalPaymentDate7;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 10th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date10;
pr.Month_4_Payment_Date__c = month4DatePlain10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 7th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date7;
pr.Month_4_Payment_Date__c = month4DatePlain7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
}
}
}
}

Hi,

 

I'd like today's date to automatically pass into a FLOW.

 

I've created a variable in my FLOW with the following attributes:

 

name=varTODAY

Data Type=Date

Input/Output Type=Input Only

Default Value=

 

I then created a button using a URL where "nax" is my org number and "flowname" is the actual name of my flow as follows:

 

https://nax.salesforce.com/flow/flowname?varTODAY=TODAY()

 

When I push the button I get an unhandled fault and the email I get explaining it says that the data types do not match.

 

The only thing I noticed was that FLOW dates look like this:  03/05/2013

And Salesforce TODAY() dates look like this: 3/5/2013

 

Could this really be causing the issue?  At a loss and would love some help.  Thanks!

 

Best,
Jeff Jobs

Hi,

 

I'm trying to create a FLOW that will lookup specific records based on a date field:

 

"How many Opportunities are there where the date field Closing_Date__c is THIS MONTH"

 

A.  Is this possible in FLOW; and B. If so, how would I go about doing this?

 

Any help would be much appreciated, thanks!

 

 

 

 

Hello Everyone,

This is the first time I've attempted to create a REST API layer for my Salesforce ORG.  I'm trying to allow my ORG to receive a REST URI and return a list of Builders (which are Accounts).  The error I get when I try to save this code in the SF Developer Console is:  Method does not exist or incorrect signature: getBuilder(String, RestRequest)

Any assistance you could provide would be greatly appreciated!  Code is below:

@RestResource(urlMapping='/v.1/builders/*')
global with sharing class RESTAPI_MYSQL_Builders {
    
    @HttpGet
    global static List<Account> doGet(RestRequest req, RestResponse res) {
        
        String name = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        
        if(name != 'builders') {
            
            return getBuilder(name, req);
        }else {
            
            return getBuilders(req);
        }
    }
    
    private static List<Account> getBuider(String name, RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        
        return Database.query('select ' + qryFields + ' from Account where name = \'' + name + '\'');
    }
    
    private static List<Account> getBuilders(RestRequest req) {
        
        //Set Defaults
        String qryFields = 'id, name';
        String qryLimit = 'limit 100';
        String qryOrderby = '';
        String qryWhere = '';
        
        //Set fields to return (If Available)
        if(req.params.containsKey('fields')) qryFields = req.params.get('fields');
        if(req.params.containsKey('limit')) qryLimit = 'limit' + req.params.get('limit');
        if(req.params.containsKey('orderby')) qryOrderby = 'order by' + req.params.get('orderby');
        if(req.params.containsKey('search')) qryWhere = 'where name LIKE \'' + req.params.get('search') + '%\'';
        
        return Database.query('select' + qryFields + ' from Account ' + qryWhere + ' ' + qryOrderby + ' ' + qryLimit);
    }
}
I'm new to Schedulable Apex and Batch Apex.  I was able to write a Test Class for my Batch Apex, but I'm having trouble writing a Test Class for the code below that schedules my Batch Apex:

global class PropertyLedgerScheduledActual implements Schedulable {
   global void execute(SchedulableContext SC) {
      PropertyLedgerBatchActual plb = new PropertyLedgerBatchActual();
      Database.executeBatch(plb);
   }
}

If someone could reply with the best practices of writing a test class for this type of Schedulable Apex, it would be greatly appreciated :)
Hi,

The purpose of this post is to confirm my understanding of Governor Limits.  In the code below, let's assume that someone will use a Data Loader to mass update 200 records.  I'd like to confirm:

1. The 2 SOQL Statements will only be run once for all 200 records (thus using 2 of an available 100)
2. The 2 DML Statements will only be run once for all 200 records (thus using 2 of an available 200 [some say 150, would like to know which])
3. That this code will support data loader updating for up to 200 records at a time via Trigger.new

Thanks in advance for your comments and time :)

Code:

trigger PropertyLedgerBouncedTrigger on Property_Ledger__c (before update) {

    //Variable Declarations
    RecordType actualFee;
    RecordType expectedFee;
    Decimal collectionAmount;
    Date collectionDate;
    String fiscalYear;
    Id opportunity = NULL;
    Id account = NULL;
    List<Property_Ledger__c> toInsert = new List<Property_Ledger__c>();
    List<Property_Fee_Reconciler__c> alsoInsert = new List<Property_Fee_Reconciler__c>();
    
    //Get the Property Ledger RecordType Ids
    actualFee = [SELECT Id FROM RecordType WHERE SObjectType = 'Property_Ledger__c' AND DeveloperName = 'Property_Actual_Fees_Ledger'];        
    expectedFee = [SELECT Id FROM RecordType WHERE SObjectType = 'Property_Ledger__c' AND DeveloperName = 'Property_Expected_Fees_Ledger'];
    
    //Iterate over the records in the trigger
    for(Property_Ledger__c pl1 :Trigger.new) {
        
        //If the Bounced Date Dump field and the Amount Dump field are filled in from the Excel Data Loader...
        if(pl1.Bounced_Date_Dump__c != NULL && pl1.Amount_Dump__c < 0) {
            
            collectionAmount = pl1.Amount_Dump__c;
            
            collectionDate = Date.newInstance(pl1.Bounced_Date_Dump__c.Year(), pl1.Bounced_Date_Dump__c.Month()+1, 25);
            
            //Account for December bounces
            if(pl1.Bounced_Date_Dump__c.Month() == 12) {
                
                collectionDate = Date.newInstance(pl1.Bounced_Date_Dump__c.Year()+1, 1, 25);
            }
            
            //Reset the Bounced Date Dump field
            pl1.Bounced_Date_Dump__c = NULL;
            
            //Set the Fiscal Year
            fiscalYear = String.valueOf(collectionDate.Year());
            
            //Avoid Null Pointer Errors
            if(pl1.Opportunity__c != NULL) {
                
                opportunity = pl1.Opportunity__c;
            }
            
            if(pl1.Account__c != NULL) {
                
                account = pl1.Account__c;
            }
            
            //Begin Amount/Date update logic
            if(collectionDate.Month() == 1) {
                
                pl1.January_Amount__c = 0;
                pl1.January_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 2) {
                
                pl1.February_Amount__c = 0;
                pl1.February_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 3) {
                
                pl1.March_Amount__c = 0;
                pl1.March_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 4) {
                
                pl1.April_Amount__c = 0;
                pl1.April_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 5) {
                
                pl1.May_Amount__c = 0;
                pl1.May_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 6) {
                
                pl1.June_Amount__c = 0;
                pl1.June_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 7) {
                
                pl1.July_Amount__c = 0;
                pl1.July_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 8) {
                
                pl1.August_Amount__c = 0;
                pl1.August_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 9) {
                
                pl1.September_Amount__c = 0;
                pl1.September_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 10) {
                
                pl1.October_Amount__c = 0;
                pl1.October_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 11) {
                
                pl1.November_Amount__c = 0;
                pl1.November_Payout_Date__c = NULL;
            }
            
            if(collectionDate.Month() == 12) {
                
                pl1.December_Amount__c = 0;
                pl1.December_Payout_Date__c = NULL;
            }
            
            //Create Fee Records and add to the toInsert List
            Property_Ledger__c actualFeeLedger = new Property_Ledger__c();
            
            actualFeeLedger.RecordTypeId = actualFee.Id;
            actualFeeLedger.Name = 'Actual Property Ledger: Late Rent Fee';
            actualFeeLedger.Property__c = pl1.Property__c;
            actualFeeLedger.Opportunity__c = opportunity;
            actualFeeLedger.Account__c = account;
            actualFeeLedger.Fiscal_Year__c = fiscalYear;
            actualFeeLedger.Description__c = 'Actual Late Fee';
            
            toInsert.add(actualFeeLedger);
            
            Property_Ledger__c expectedFeeLedger = new Property_Ledger__c();
            
            expectedFeeLedger.RecordTypeId = expectedFee.Id;
            expectedFeeLedger.Name = 'Expected Property Ledger: Late Rent Fee';
            expectedFeeLedger.Property__c = pl1.Property__c;
            expectedFeeLedger.Opportunity__c = opportunity;
            expectedFeeLedger.Account__c = account;
            expectedFeeLedger.Fiscal_Year__c = fiscalYear;
            expectedFeeLedger.Fee_Amount__c = 50.00;
            expectedFeeLedger.Collection_Date__c = collectionDate;
            expectedFeeLedger.Description__c = 'Expected Late Rent Fee';
            
            toInsert.add(expectedFeeLedger);
            
            Property_Fee_Reconciler__c feesReconciler = new Property_Fee_Reconciler__c();
            
            feesReconciler.Expected_Fee__c = expectedFeeLedger.Id;
            feesReconciler.Actual_Fee__c = actualFeeLedger.Id;
            
            alsoInsert.add(feesReconciler);
            
            Property_Ledger__c actualLateRentLedger = new Property_Ledger__c();
            
            actualLateRentLedger.RecordTypeId = actualFee.Id;
            actualLateRentLedger.Name = 'Actual Property Ledger: Delinquent Rent';
            actualLateRentLedger.Property__c = pl1.Property__c;
            actualLateRentLedger.Opportunity__c = opportunity;
            actualLateRentLedger.Account__c = account;
            actualLateRentLedger.Fiscal_Year__c = fiscalYear;
            actualLateRentLedger.Description__c = 'Actual Delinquent Rent Collected';
            
            toInsert.add(actualLateRentLedger);
            
            Property_Ledger__c expectedLateRentLedger = new Property_Ledger__c();
            
            expectedLateRentLedger.RecordTypeId = expectedFee.Id;
            expectedLateRentLedger.Name = 'Expected Property Ledger: Delinquent Rent';
            expectedLateRentLedger.Property__c = pl1.Property__c;
            expectedLateRentLedger.Opportunity__c = opportunity;
            expectedLateRentLedger.Account__c = account;
            expectedLateRentLedger.Fiscal_Year__c = fiscalYear;
            expectedLateRentLedger.Fee_Amount__c = collectionAmount;
            expectedLateRentLedger.Collection_Date__c = collectionDate;
            expectedLateRentLedger.Description__c = 'Expected Delinquent Rent Collected';
            
            toInsert.add(expectedLateRentLedger);
            
            Property_Fee_Reconciler__c rentReconciler = new Property_Fee_Reconciler__c();
            
            rentReconciler.Expected_Fee__c = expectedLateRentLedger.Id;
            rentReconciler.Actual_Fee__c = actualLateRentLedger.Id;
            
            alsoInsert.add(rentReconciler);
        }
    }
    
    //If there are records in the toInsert List, insert them and the alsoInsert List into the database
    if(toInsert.size() > 0) {
        
        insert toInsert;
        insert alsoInsert;
    }
}
Hi,
I'm trying to create some Date Logic in an Apex Class.  Everything I do works exactly how I want, but I can't get coverage on part of the code no matter what I try.  I've included a screenshot:
User-added image
Essentially I'm trying to create two date variables "nextPayDay" and "nextClosingPayDay" based on date fields that are found on my payout object (p).  I include a scenario in my test class where the month + 1 ends up being January (1) and when I do a system.assertEquals, I can see that the year has gone up by 1.  However, it is still red in the test class.  Any help would be greatly appreciated!
 
Hi,

I'm looking for a solution where the end-user logs into Salesforce and, upon login, another browser tab opens to an external website (example: cnn.com).  If it was just me, I would set my browser to launch specific tabs on startup, but I'm trying to set this up for about 90 people (not many are computer saavy) in my ORG and my superior is wondering if I could automate this when they login to Salesforce. 

Any help, or alternative solutions, would be greatly appreciated.  Thanks!
Goal is to enter info on an object, then enter different info on another object by creating multiple records.  So we have an update and multiple inserts.

I'm using buttons to go from from one page to the next and then I'd like a "Make Another" button to simply duplicate the second piece ad infinitum.  Here is what I have so far:

<apex:page standardController="SODA__c" extensions="PutbackExtension">
 
  <apex:sectionHeader title="Create Putback Work - Update SODA"/>
 
  <apex:form >
    <apex:pageBlock >
     
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandButton action="{!save}" value="DONE"/>
        <apex:commandButton action="{!ToRST}" value="Create Resident Service Ticket"/>
      </apex:pageBlockButtons>
     
      <apex:pageBlockSection title="Enter Standard Putback Activity Amounts (If Applicable)" columns="1" collapsible="false">
        <apex:inputField value="{!SODA__c.House_Cleaning_Fee__c}" label="House Cleaning Fee"/>
        <apex:inputField value="{!SODA__c.Carpet_Cleaning_Fee__c}" label="Carpet Cleaning Fee"/>
        <apex:inputField value="{!SODA__c.Painting_Patching_Fee__c}" label="Painting/Patching Fee"/>
      </apex:pageBlockSection>
     
      <apex:pageBlockSection title="Enter Other Putback Activities and Amounts" columns="2" collapsible="false">
        <apex:inputField value="{!SODA__c.Other_Fee_1_Description_Long__c}" label="Other 1 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_1__c}" label="Other 1 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_2_Description_Long__c}" label="Other 2 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_2__c}" label="Other 2 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_3_Description_Long__c}" label="Other 3 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_3__c}" label="Other 3 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_4_Description_Long__c}" label="Other 4 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_4__c}" label="Other 4 Fee"/>
        <apex:inputField value="{!SODA__c.Other_Fee_5_Description_Long__c}" label="Other 5 Description"/>
        <apex:inputField value="{!SODA__c.Other_Fee_5__c}" label="Other 5 Fee"/>
      </apex:pageBlockSection>
     
    </apex:pageBlock> 
  </apex:form>
</apex:page>


(Second VF Page)
<apex:page standardController="Resident_Service_Tickets__c" extensions="PutbackExtension">
  <apex:sectionHeader title="Create Putback Work - New Resident Service Ticket"/>
  <apex:form >
    <apex:pageBlock >
   
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton immediate="true" action="{!CancelRST}" value="Cancel"/>
        <apex:commandButton action="{!ToRST}" value="Make Another"/>
        <apex:commandButton action="{!save}" value="DONE"/>       
      </apex:pageBlockButtons>
     
      <apex:pageBlockSection title="Enter Putback Service Information" columns="1" collapsible="false">
        <apex:inputField value="{!Resident_Service_Tickets__c.Winning_Trade__c}" label="Trade" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Method_of_Payment_for_Trade__c}" label="Method of Payment" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Amount_Billed_to_MH__c}" label="Billing Amount" required="true"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Notes__c}" label="Work Done" required="true"/>
      </apex:pageBlockSection>
     
      <apex:pageBlockSection title="Object Relationships" columns="1" id="section1">
        <!-- <script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]); </script> -->
        <apex:inputField value="{!Resident_Service_Tickets__c.Concierge__c}" label="Concierge"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Resident_Account__c}" label="Resident Account"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Resident_Opportunity__c}" label="Resident Opportunity"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Property__c}" label="Property"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.Owner_Account__c}" label="Owner Account"/>
        <apex:inputField value="{!Resident_Service_Tickets__c.SODA__c}" label="SODA"/>
      </apex:pageBlockSection>
   
    </apex:pageBlock>
  </apex:form>
</apex:page>


(Extension Class)
public class PutbackExtension {

    //Declare Instance Variables
    private ApexPages.StandardController sc;
    private Id soda;
    private Id con;
    private Id roppId;
    private Opportunity ropp;
    private Id racc;
    private Id propId;
    private Property__c prop;
    private String putback;
    private Id acc;
   
    //Create Constructor
    public PutbackExtension(ApexPages.StandardController standardController) {
   
        sc = standardController;
       
        if(ApexPages.currentPage().getParameters().get('soda') == '123') {
       
            soda = ApexPages.currentPage().getParameters().get('id');
        }
       
        if(ApexPages.currentPage().getParameters().get('soda') != '123') {
       
            soda = ApexPages.currentPage().getParameters().get('soda');
        }   
       
        roppId = ApexPages.currentPage().getParameters().get('ropp');
        ropp = [SELECT Id, AccountId FROM Opportunity WHERE Id = :roppId];
        racc = ropp.AccountId;
        propId = ApexPages.currentPage().getParameters().get('prop');
        prop = [SELECT Id, Home_Sale_Opportunity__c, Concierge__c FROM Property__c WHERE Id = :propId];
        con = prop.Concierge__c;
        putback = 'PUTBACK';
        Opportunity opp =[SELECT Id, AccountId FROM Opportunity WHERE Id = :prop.Home_Sale_Opportunity__c];
        acc = opp.AccountId;
    }
   
    //Methods
    public PageReference ToRST() {
   
        sc.Save();
       
        Resident_Service_Tickets__c rstRecord = new Resident_Service_Tickets__c();
        rstRecord.Concierge__c = con;
        rstRecord.Resident_Account__c = racc;
        rstRecord.Resident_Opportunity__c = roppId;
        rstRecord.Owner_Account__c = acc;
        rstRecord.Property__c = propId;
        rstRecord.Troubleshooting_Notes__c = putback;
        rstRecord.SODA__c = soda;
        insert rstRecord;
       
        //rstRecord = (Resident_Service_Tickets__c)sc.getRecord();
       
        String soda = ApexPages.currentPage().getParameters().get('id');
        String ropp = ApexPages.currentPage().getParameters().get('ropp');
        String prop = ApexPages.currentPage().getParameters().get('prop');
        String con = ApexPages.currentPage().getParameters().get('con');
               
        PageReference rst = new PageReference('/apex/PutbackPage2?id='+rstRecord.Id+'&soda='+soda+'&ropp='+ropp+'&prop='+prop+'&con='+con+'&rst='+rstRecord.Id);
       
        return rst;
    }      
   
    public PageReference CancelRST() {
   
        String rst = ApexPages.currentPage().getParameters().get('rst');
       
        String soda = ApexPages.currentPage().getParameters().get('soda');
       
        delete [SELECT Id FROM Resident_Service_Tickets__c WHERE Id = :rst];
       
        PageReference start = new PageReference('/'+soda);
       
        return start;
    }
}

It works but when I go to make another Resident Service Ticket (when I push "Make Another") it still shows me the last one filled in as displayed below:

User-added image

I'm know I'm probably missing something with refreshing the standard controller but I'm really at a loss here.  Any help would be greatly apprecitated.  Thanks!

Hi,

 

New to VF so pardon the ignorance.

 

Let's begin with the objective:

 

I decide which Opportunities need to be edited based on specific criteria.  Then I want users to enter in deal numbers and update all the opportunities on the screens.  

 

Here is the code I have:

 

VF:

 

<apex:page controller="listDealNumbers">
<apex:form >
<apex:pageBlock title="Assign Deal Numbers">
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!assign}" value="Assign"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column headerValue="Opportunity">
<apex:outputLink value="https://cs9.salesforce.com/{!opp.Id}" target="_blank">{!Opp.Name}</apex:outputlink>
</apex:column>
<apex:column headerValue="Cha-Ching Date">
<apex:outputField value="{!opp.Cha_Ching_Date_v2__c}"/>
</apex:column>
<apex:column headerValue="Deal Number This Month">
<apex:inputField value="{!opp.Deal_Number_This_Month__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

APEX:

 

public class listDealNumbers {

public List<Opportunity> getOpportunities() {

date myDate = date.Today();
date startOfMonth = myDate.toStartOfMonth();
date startOfLastMonth = startOfMonth.addMonths(-1);
id userId = UserInfo.getUserId();

return [SELECT o.Id, o.Owner.Id, o.Name, o.Cha_Ching_Date_V2__c, o.Deal_Number_This_Month__c FROM Opportunity o
WHERE o.Cha_Ching_Date_V2__c >= :startOfLastMonth AND o.Cha_Ching_Date_V2__c < :startOfMonth AND o.Owner.Id = :userId
ORDER BY o.Cha_Ching_Date_V2__c];
}


public PageReference assign() {
return null;
}

}

 

So everything works but I'm not sure how to use the "assign" method to update the Opportunity Records.  I'd like to just say "update opportunities" but that won't work.  So please help with the missing "update" code I need in the "assign" method.  Thanks so much for any help :)

Hi,

 

I'm writing a test class where I'm testing a "before update" scenario.  

 

Original Class is:

 

public class paymentRecordHandlerRentIn{

//Create a method for GTM Deals
public static void rentIn (Payment_Record__c[] paymentRecords) {

for (Payment_Record__c pr: paymentRecords) {

//Declare Variables
Date month1Date = pr.Move_In_Date__c;
Date month2Date = (((pr.Move_In_Date__c.toStartOfMonth()).addMonths(1)).addDays(24));
Date month3Date = month2Date.addMonths(1);
Date month4Date = month3Date.addMonths(1);
Date month5Date = month4Date.addMonths(1);
Date month6Date = month5Date.addMonths(1);
Date month7Date = month6Date.addMonths(1);
Date month8Date = month7Date.addMonths(1);
Date month9Date = month8Date.addMonths(1);
Date month10Date = month9Date.addMonths(1);
Date month11Date = month10Date.addMonths(1);
Date month12Date = month11Date.addMonths(1);
Date month13Date = month12Date.addMonths(1);
Date month14Date = month13Date.addMonths(1);
Date month15Date = month14Date.addMonths(1);
Date month16Date = month15Date.addMonths(1);
Date month17Date = month16Date.addMonths(1);
Date month18Date = month17Date.addMonths(1);
Date month19Date = month18Date.addMonths(1);
Date month20Date = month19Date.addMonths(1);
Date month21Date = month20Date.addMonths(1);
Date month22Date = month21Date.addMonths(1);
Date month23Date = month22Date.addMonths(1);
Date month24Date = month23Date.addMonths(1);
Date month25Date = month24Date.addMonths(1);
Date month26Date = month25Date.addMonths(1);
Date month27Date = month26Date.addMonths(1);
Date month28Date = month27Date.addMonths(1);
Date month29Date = month28Date.addMonths(1);
Date month30Date = month29Date.addMonths(1);
Date month31Date = month30Date.addMonths(1);
Date month32Date = month31Date.addMonths(1);
Date month33Date = month32Date.addMonths(1);
Date month34Date = month33Date.addMonths(1);
Date month35Date = month34Date.addMonths(1);
Date month36Date = month35Date.addMonths(1);
Date month37Date = month36Date.addMonths(1);
Date month38Date = month37Date.addMonths(1);
Date month39Date = month38Date.addMonths(1);
Date month40Date = month39Date.addMonths(1);
Date month41Date = month40Date.addMonths(1);
Date month42Date = month41Date.addMonths(1);
Date month43Date = month42Date.addMonths(1);
Date month44Date = month43Date.addMonths(1);
Date month45Date = month44Date.addMonths(1);
Date month46Date = month45Date.addMonths(1);
Date month47Date = month46Date.addMonths(1);
Date month48Date = month47Date.addMonths(1);
Date month49Date = month48Date.addMonths(1);
Date month50Date = month49Date.addMonths(1);
Date month51Date = month50Date.addMonths(1);
Date month52Date = month51Date.addMonths(1);
Date month53Date = month52Date.addMonths(1);
Date month54Date = month53Date.addMonths(1);
Date month55Date = month54Date.addMonths(1);
Date month56Date = month55Date.addMonths(1);
Date month57Date = month56Date.addMonths(1);
Date month58Date = month57Date.addMonths(1);
Date month59Date = month58Date.addMonths(1);
Date month60Date = month59Date.addMonths(1);
Date finalPaymentDate = month60Date.addMonths(1);

Decimal fPRP = pr.Prorated_Rent_Amount__c;
Decimal rFR1 = pr.Rent_from_Resident_Year_One__c;
Decimal rFR2 = pr.Rent_from_Resident_Year_Two__c;
Decimal rFR3 = pr.Rent_from_Resident_Year_Three__c;
Decimal rFR4 = pr.Rent_from_Resident_Year_Four__c;
Decimal rFR5 = pr.Rent_from_Resident_Year_Five__c;

//Standard Rent Agreement
if(pr.RecordTypeId == '012J00000000MgB') {

//Print "No Matter What" fields
pr.Month_1_Payment_Date__c = month1Date;
pr.Month_2_Payment_Amount__c = rFR1;
pr.Month_2_Payment_Date__c = month2Date;
pr.Month_3_Payment_Amount__c = rFR1;
pr.Month_3_Payment_Date__c = month3Date;
pr.Month_4_Payment_Amount__c = rFR1;
pr.Month_4_Payment_Date__c = month4Date;
pr.Month_5_Payment_Amount__c = rFR1;
pr.Month_5_Payment_Date__c = month5Date;
pr.Month_6_Payment_Amount__c = rFR1;
pr.Month_6_Payment_Date__c = month6Date;
pr.Month_7_Payment_Amount__c = rFR1;
pr.Month_7_Payment_Date__c = month7Date;
pr.Month_8_Payment_Amount__c = rFR1;
pr.Month_8_Payment_Date__c = month8Date;
pr.Month_9_Payment_Amount__c = rFR1;
pr.Month_9_Payment_Date__c = month9Date;
pr.Month_10_Payment_Amount__c = rFR1;
pr.Month_10_Payment_Date__c = month10Date;
pr.Month_11_Payment_Amount__c = rFR1;
pr.Month_11_Payment_Date__c = month11Date;
pr.Month_12_Payment_Amount__c = rFR1;
pr.Month_12_Payment_Date__c = month12Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Month_1_Payment_Type__c = 'First Prorated Rent Amount';
pr.Month_1_Payment_Amount__c = fPRP;
pr.Final_Payment_Amount__c = rFR1;
pr.Final_Payment_Date__c = finalPaymentDate;

//No Prorated Rent
}Else if (pr.Override_Prorated_Rent__c == TRUE) {

pr.Month_1_Payment_Type__c = 'Standard Rent Payment';
pr.Month_1_Payment_Amount__c = rFR1;
}

//Begin Multi-Year Logic

//Year One
}Else if(pr.RecordTypeId == '012J00000000LyZ') {

//Print "No Matter What" fields
pr.Month_1_Payment_Date__c = month1Date;
pr.Month_2_Payment_Amount__c = rFR1;
pr.Month_2_Payment_Date__c = month2Date;
pr.Month_3_Payment_Amount__c = rFR1;
pr.Month_3_Payment_Date__c = month3Date;
pr.Month_4_Payment_Amount__c = rFR1;
pr.Month_4_Payment_Date__c = month4Date;
pr.Month_5_Payment_Amount__c = rFR1;
pr.Month_5_Payment_Date__c = month5Date;
pr.Month_6_Payment_Amount__c = rFR1;
pr.Month_6_Payment_Date__c = month6Date;
pr.Month_7_Payment_Amount__c = rFR1;
pr.Month_7_Payment_Date__c = month7Date;
pr.Month_8_Payment_Amount__c = rFR1;
pr.Month_8_Payment_Date__c = month8Date;
pr.Month_9_Payment_Amount__c = rFR1;
pr.Month_9_Payment_Date__c = month9Date;
pr.Month_10_Payment_Amount__c = rFR1;
pr.Month_10_Payment_Date__c = month10Date;
pr.Month_11_Payment_Amount__c = rFR1;
pr.Month_11_Payment_Date__c = month11Date;
pr.Month_12_Payment_Amount__c = rFR1;
pr.Month_12_Payment_Date__c = month12Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Month_1_Payment_Type__c = 'First Prorated Rent Amount';
pr.Month_1_Payment_Amount__c = fPRP;

//No Prorated Rent
}Else if (pr.Override_Prorated_Rent__c == TRUE) {

pr.Month_1_Payment_Type__c = 'Standard Rent Payment';
pr.Month_1_Payment_Amount__c = rFR1;
}

//Year Two
}Else if (pr.RecordTypeId == '012J00000000MgG') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR2;
pr.Month_1_Payment_Date__c = month13Date;
pr.Month_2_Payment_Amount__c = rFR2;
pr.Month_2_Payment_Date__c = month14Date;
pr.Month_3_Payment_Amount__c = rFR2;
pr.Month_3_Payment_Date__c = month15Date;
pr.Month_4_Payment_Amount__c = rFR2;
pr.Month_4_Payment_Date__c = month16Date;
pr.Month_5_Payment_Amount__c = rFR2;
pr.Month_5_Payment_Date__c = month17Date;
pr.Month_6_Payment_Amount__c = rFR2;
pr.Month_6_Payment_Date__c = month18Date;
pr.Month_7_Payment_Amount__c = rFR2;
pr.Month_7_Payment_Date__c = month19Date;
pr.Month_8_Payment_Amount__c = rFR2;
pr.Month_8_Payment_Date__c = month20Date;
pr.Month_9_Payment_Amount__c = rFR2;
pr.Month_9_Payment_Date__c = month21Date;
pr.Month_10_Payment_Amount__c = rFR2;
pr.Month_10_Payment_Date__c = month22Date;
pr.Month_11_Payment_Amount__c = rFR2;
pr.Month_11_Payment_Date__c = month23Date;
pr.Month_12_Payment_Amount__c = rFR2;
pr.Month_12_Payment_Date__c = month24Date;
pr.Stop_Code__c = TRUE;

//Year Three
}Else if (pr.RecordTypeId == '012J00000000MgL') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR3;
pr.Month_1_Payment_Date__c = month25Date;
pr.Month_2_Payment_Amount__c = rFR3;
pr.Month_2_Payment_Date__c = month26Date;
pr.Month_3_Payment_Amount__c = rFR3;
pr.Month_3_Payment_Date__c = month27Date;
pr.Month_4_Payment_Amount__c = rFR3;
pr.Month_4_Payment_Date__c = month28Date;
pr.Month_5_Payment_Amount__c = rFR3;
pr.Month_5_Payment_Date__c = month29Date;
pr.Month_6_Payment_Amount__c = rFR3;
pr.Month_6_Payment_Date__c = month30Date;
pr.Month_7_Payment_Amount__c = rFR3;
pr.Month_7_Payment_Date__c = month31Date;
pr.Month_8_Payment_Amount__c = rFR3;
pr.Month_8_Payment_Date__c = month32Date;
pr.Month_9_Payment_Amount__c = rFR3;
pr.Month_9_Payment_Date__c = month33Date;
pr.Month_10_Payment_Amount__c = rFR3;
pr.Month_10_Payment_Date__c = month34Date;
pr.Month_11_Payment_Amount__c = rFR3;
pr.Month_11_Payment_Date__c = month35Date;
pr.Month_12_Payment_Amount__c = rFR3;
pr.Month_12_Payment_Date__c = month36Date;
pr.Stop_Code__c = TRUE;

//Year Four
}Else if (pr.RecordTypeId == '012J00000000MgQ') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR4;
pr.Month_1_Payment_Date__c = month37Date;
pr.Month_2_Payment_Amount__c = rFR4;
pr.Month_2_Payment_Date__c = month38Date;
pr.Month_3_Payment_Amount__c = rFR4;
pr.Month_3_Payment_Date__c = month39Date;
pr.Month_4_Payment_Amount__c = rFR4;
pr.Month_4_Payment_Date__c = month40Date;
pr.Month_5_Payment_Amount__c = rFR4;
pr.Month_5_Payment_Date__c = month41Date;
pr.Month_6_Payment_Amount__c = rFR4;
pr.Month_6_Payment_Date__c = month42Date;
pr.Month_7_Payment_Amount__c = rFR4;
pr.Month_7_Payment_Date__c = month43Date;
pr.Month_8_Payment_Amount__c = rFR4;
pr.Month_8_Payment_Date__c = month44Date;
pr.Month_9_Payment_Amount__c = rFR4;
pr.Month_9_Payment_Date__c = month45Date;
pr.Month_10_Payment_Amount__c = rFR4;
pr.Month_10_Payment_Date__c = month46Date;
pr.Month_11_Payment_Amount__c = rFR4;
pr.Month_11_Payment_Date__c = month47Date;
pr.Month_12_Payment_Amount__c = rFR4;
pr.Month_12_Payment_Date__c = month48Date;
pr.Stop_Code__c = TRUE;

//Year Five
}Else if (pr.RecordTypeId == '012J00000000MgH') {

//Print Variables
pr.Month_1_Payment_Amount__c = rFR5;
pr.Month_1_Payment_Date__c = month49Date;
pr.Month_2_Payment_Amount__c = rFR5;
pr.Month_2_Payment_Date__c = month50Date;
pr.Month_3_Payment_Amount__c = rFR5;
pr.Month_3_Payment_Date__c = month51Date;
pr.Month_4_Payment_Amount__c = rFR5;
pr.Month_4_Payment_Date__c = month52Date;
pr.Month_5_Payment_Amount__c = rFR5;
pr.Month_5_Payment_Date__c = month53Date;
pr.Month_6_Payment_Amount__c = rFR5;
pr.Month_6_Payment_Date__c = month54Date;
pr.Month_7_Payment_Amount__c = rFR5;
pr.Month_7_Payment_Date__c = month55Date;
pr.Month_8_Payment_Amount__c = rFR5;
pr.Month_8_Payment_Date__c = month56Date;
pr.Month_9_Payment_Amount__c = rFR5;
pr.Month_9_Payment_Date__c = month57Date;
pr.Month_10_Payment_Amount__c = rFR5;
pr.Month_10_Payment_Date__c = month58Date;
pr.Month_11_Payment_Amount__c = rFR5;
pr.Month_11_Payment_Date__c = month59Date;
pr.Month_12_Payment_Amount__c = rFR5;
pr.Month_12_Payment_Date__c = month60Date;
pr.Stop_Code__c = TRUE;

//Prorated Rent
if (pr.Override_Prorated_Rent__c == FALSE) {

pr.Final_Payment_Amount__c = rFR5;
pr.Final_Payment_Date__c = finalPaymentDate;
}
}

}

}

}

 

Test Class is:

 

@isTest

 

public class paymentRecordsTestRentIn{

static testMethod void standardTest() {

//Create Fake Records
RecordType rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Account' AND isActive = true AND DeveloperName like '%Person_Account%' LIMIT 1];
Account a = new Account();
a.RecordTypeId = rt.Id;
a.LastName = 'test';
insert a;

Property__c prop = new Property__c();
prop.Address_Line_1__c = '123 Street';
prop.Name = '123 Street';
insert prop;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity oppR1 = new Opportunity();
oppR1.AccountId = a.Id;
oppR1.Name = 'test';
oppR1.StageName = 'test';
oppR1.CloseDate = system.today();
oppR1.RecordTypeId = rt.Id;
oppR1.Property__c = prop.Id;
oppR1.Move_In_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_End_Date__c = date.parse('05/17/2014');
oppR1.Days_of_the_Month__c = 31;
oppR1.Rent_From_Resident__c = 1000;
insert oppR1;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity oppR2 = new Opportunity();
oppR2.AccountId = a.Id;
oppR2.Name = 'test';
oppR2.StageName = 'test';
oppR2.CloseDate = system.today();
oppR2.RecordTypeId = rt.Id;
oppR2.Property__c = prop.Id;
oppR1.Move_In_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_Date__c = date.parse('05/17/2013');
oppR1.Resident_Lease_End_Date__c = date.parse('05/17/2014');
oppR2.Days_of_the_Month__c = 31;
oppR2.Rent_From_Resident__c = 1000;
oppR2.Rent_From_Resident_Year_2__c = 1050;
oppR2.Rent_From_Resident_Year_3__c = 1100;
oppR2.Rent_From_Resident_Year4__c = 1150;
oppR2.Rent_From_Resident_Year_5__c = 1200;
insert oppR2;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Payment_Record__c' AND isActive = true AND DeveloperName like '%Rent_In%' LIMIT 1];
Payment_Record__c prHS1 = new Payment_Record__c();
prHS1.RecordTypeId = rt.Id;
prHS1.Opportunity__c = oppR1.id;
prHS1.Property__c = prop.id;
insert prHS1;

 

//Begin Testing

Test.startTest();

prHS1.Override_Prorated_Rent__c = FALSE;
update prHS1;

prHS1 = [Select id, Month_1_Payment_Type__c, Month_1_Payment_Amount__c, Month_1_Payment_Date__c,
Month_2_Payment_Amount__c, Month_2_Payment_Date__c, Final_Payment_Amount__c, Final_Payment_Date__c, Move_In_Date__c,
Stop_Code__c, Override_Prorated_Rent__c
From Payment_Record__c Where Id = :prHS1.id];

//Standard Rent with Prorated Rent Test
system.assert(prHS1.Month_1_Payment_Type__c == 'First Prorated Rent Amount'); //Line 69
system.assert(prHS1.Month_1_Payment_Amount__c == 483.87);
system.assert(prHS1.Month_1_Payment_Date__c == prHS1.Move_In_Date__c);
system.assert(prHS1.Month_2_Payment_Amount__c == 1000);
system.assert(prHS1.Month_2_Payment_Date__c == (((prHS1.Move_In_Date__c.toStartOfMonth()).addMonths(1)).addDays(24)));
system.assert(prHS1.Stop_Code__c == TRUE);

Test.stopTest();
}

}

 

Error Message is:

 

Assertion Failed at Line 69

 

I've marked Line 69 in comment code

 

What's happening is that even though I'm typing "update prHS1" no update is taking place.  Thus, the field at line 69 is null and passes if I type "== null" instead of my string.  I should mention that the original class code works when put into practice, and that no errors are provided in the developer console.  Obviously, I'm missing a huge piece for "before update" test classes (this is my first one).  

 

Any help would be appreciated.  Under a tight deadline, so would appreciate any thoughts sooner rather than later.  Thanks!

Hi all,

 

Still new to Apex and am having trouble with this test class:

 

@isTest

public class emailHandlerTest {

static testMethod void emailTest() {

//Create fake records
RecordType rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Account' AND isActive = true AND DeveloperName like '%Person_Account%' LIMIT 1];
Account a = new Account();
a.RecordTypeId = rt.Id;
a.LastName = 'test';
insert a;

Property__c prop = new Property__c();
prop.Address_Line_1__c = '123 Street';
prop.Name = '123 Street';
insert prop;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity opp = new Opportunity();
opp.AccountId = a.Id;
opp.Name = 'test';
opp.StageName = 'test';
opp.CloseDate = system.today();
opp.RecordTypeId = rt.Id;
opp.Property__c = prop.Id;
insert opp;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Applicants__c' AND isActive = true AND Name like '%Primary_Applicant%' LIMIT 1];
Applicants__c app = new Applicants__c();
app.RecordTypeId = rt.Id;
app.Opportunity_Name__c = opp.Id;
app.Property__c = prop.Id;
app.Applicant_Email__c = 'test@test.com';

//Initiate Test One - Will the first email field fill in after an applicant record is inserted?
Test.startTest();

insert app;

Test.stopTest();

system.assert(opp.Additional_Applicant_1__c == 'test@test.com'); //This is Line 43
}
}

 

Actual Trigger being tested is here:

 

trigger emailHandler on Applicants__c (after insert) {

Set<ID> opportunityIds = new Set<ID>();

for (Applicants__c a: trigger.new) {

opportunityIds.add(a.Opportunity_Name__c);
}

List<Applicants__c> applicantEmail = [Select id, Applicant_Email__c From Applicants__c Where id in: Trigger.new];

List<Opportunity> emailFields = [Select id, Additional_Applicant_1__c, Additional_Applicant_2__c,Additional_Applicant_3__c,Additional_Applicant_4__c
From Opportunity
Where id in: opportunityIds];

for (Opportunity o: emailFields) {

for (Applicants__c a: applicantEmail) {

String email = a.Applicant_Email__c;

if (o.Additional_Applicant_1__c == null) {

o.Additional_Applicant_1__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c == null) {

o.Additional_Applicant_2__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c == null) {

o.Additional_Applicant_3__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c <> null && o.Additional_Applicant_4__c == null) {

o.Additional_Applicant_4__c = email;
}
}
}

update emailFields;
}

 

As you can see I'm creating fake records so that I can fulfill the required fields on my Applicant__c object.  I have to have an account to create the property, a property to create the opportunity, etc.  

 

The trigger I'm testing is "after insert" so that's why I'm putting the "insert app" line in within the test; because I want to see what happens to the opportunity after an applicant record is inserted.  What should happen is that "test@test.com" gets put in an opportunity field called "Additional_Applicant_1__c".

 

I'm using the Developer Console and there are no errors to solve.  I run the test and get "Assertion Failed" at line 43, which I take to mean that "test@test.com" is NOT present on that field.

 

The trouble is that an actual test of this code works perfectly (meaning if I physically create the applicant record instead of using the test class).

 

Bottom Line: I know the code works, but I can't get the test class to prove it.  Please help!

 

Hi Everyone,

 

I'm very new to Apex so please forgive a few noob errors.  

 

I'm using Apex for date logic, something FLOW falls short on.  The following Trigger works "before update" in tandem with my FLOW.  So the FLOW creates a record, then "updates" it which instantiates the Trigger.   The problem is, all of the FLOW stuff works, and NONE of the Apex stuff works and there is NOT an error message.  The dates I want from Apex just don't show up.  I've also tried manually creating the the record (no FLOW) with the exact same date results.  Please help.  I know I'm missing something :)

 

trigger RentOutPaymentRecordDateLogic on Payment_Record__c (before update) {

//Create Payment Record Collection
List<Payment_Record__c> RentOutPaymentRecords =
[Select j.RecordTypeId, j.First_Payment_Date__c, j.Waiver_Period_In_Days__c, j.Payout_Day__c, j.Override_Prorated_Rent__c
From Payment_Record__c j
Where j.RecordTypeId = '012d0000000wnuF'
And Payment_Record__c.id IN: Trigger.new
For Update];

//Iterate through Payment Records
for (Payment_Record__c pr: RentOutPaymentRecords) {
RentOutPaymentRecordCreation.dateUpdates(RentOutPaymentRecords);
}
}

 

public class RentOutPaymentRecordCreation{

public static void dateUpdates (Payment_Record__c[] RentOutPaymentRecords) {

for (Payment_Record__c pr: RentOutPaymentRecords) {

//Declare Date Variables
Date month3Date7 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(6));
Date month3Date10 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(9));
Date month4DatePlain7 = month3Date7.addMonths(1);
Date month4DatePlain10 = month3Date10.addMonths(1);
Date month4Date7 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(6));
Date month4Date10 = (((pr.First_Payment_Date__c.toStartOfMonth()).addMonths(1)).addDays(9));
Date month5Date7 = month4Date7.addMonths(1);
Date month5Date10 = month4Date10.addMonths(1);
Date month6Date7 = month5Date7.addMonths(1);
Date month6Date10 = month5Date10.addMonths(1);
Date month7Date7 = month6Date7.addMonths(1);
Date month7Date10 = month6Date10.addMonths(1);
Date month8Date7 = month7Date7.addMonths(1);
Date month8Date10 = month7Date10.addMonths(1);
Date month9Date7 = month8Date7.addMonths(1);
Date month9Date10 = month8Date10.addMonths(1);
Date month10Date7 = month9Date7.addMonths(1);
Date month10Date10 = month9Date10.addMonths(1);
Date month11Date7 = month10Date7.addMonths(1);
Date month11Date10 = month10Date10.addMonths(1);
Date month12Date7 = month11Date7.addMonths(1);
Date month12Date10 = month11Date10.addMonths(1);
Date finalPaymentDate7 = month12Date7.addMonths(1);
Date finalPaymentDate10 = month12Date10.addMonths(1);

if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 10th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;
pr.Final_Payment_Date__c = finalPaymentDate10;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 7th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
pr.Final_Payment_Date__c = finalPaymentDate7;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 10th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;

} Else if (pr.Waiver_Period_in_Days__c == 60 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 60 Day Waiver, Payout on the 7th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = null;
pr.Month_3_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_4_Payment_Date__c = month4Date7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 10th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date10;
pr.Month_4_Payment_Date__c = month4DatePlain10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;
pr.Final_Payment_Date__c = finalPaymentDate10;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == FALSE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 7th, and Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date7;
pr.Month_4_Payment_Date__c = month4DatePlain7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
pr.Final_Payment_Date__c = finalPaymentDate7;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 10 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 10th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date10;
pr.Month_4_Payment_Date__c = month4DatePlain10;
pr.Month_5_Payment_Date__c = month5Date10;
pr.Month_6_Payment_Date__c = month6Date10;
pr.Month_7_Payment_Date__c = month7Date10;
pr.Month_8_Payment_Date__c = month8Date10;
pr.Month_9_Payment_Date__c = month9Date10;
pr.Month_10_Payment_Date__c = month10Date10;
pr.Month_11_Payment_Date__c = month11Date10;
pr.Month_12_Payment_Date__c = month12Date10;

} Else if (pr.Waiver_Period_in_Days__c == 30 && pr.Payout_Day__c == 7 && pr.Override_Prorated_Rent__c == TRUE) {

//Design Date Fields Update for 30 Day Waiver, Payout on the 7th, and No Prorated Rent
pr.Month_1_Payment_Date__c = null;
pr.Month_2_Payment_Date__c = pr.First_Payment_Date__c;
pr.Month_3_Payment_Date__c = month3Date7;
pr.Month_4_Payment_Date__c = month4DatePlain7;
pr.Month_5_Payment_Date__c = month5Date7;
pr.Month_6_Payment_Date__c = month6Date7;
pr.Month_7_Payment_Date__c = month7Date7;
pr.Month_8_Payment_Date__c = month8Date7;
pr.Month_9_Payment_Date__c = month9Date7;
pr.Month_10_Payment_Date__c = month10Date7;
pr.Month_11_Payment_Date__c = month11Date7;
pr.Month_12_Payment_Date__c = month12Date7;
}
}
}
}

Hi,

 

I'd like today's date to automatically pass into a FLOW.

 

I've created a variable in my FLOW with the following attributes:

 

name=varTODAY

Data Type=Date

Input/Output Type=Input Only

Default Value=

 

I then created a button using a URL where "nax" is my org number and "flowname" is the actual name of my flow as follows:

 

https://nax.salesforce.com/flow/flowname?varTODAY=TODAY()

 

When I push the button I get an unhandled fault and the email I get explaining it says that the data types do not match.

 

The only thing I noticed was that FLOW dates look like this:  03/05/2013

And Salesforce TODAY() dates look like this: 3/5/2013

 

Could this really be causing the issue?  At a loss and would love some help.  Thanks!

 

Best,
Jeff Jobs