• Adam Rycroft
  • NEWBIE
  • 105 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 12
    Replies
Hi,
I am trying to create a formula field that concatenates a text field and a date field. Is there anyway around this?

Status__c &" - "& StatusActionDate__c


Thanks,
Alex
Hi,

We have a LWC component built by an outside developer that needs to be edited. How do you edit an existing compenent?
Hi,

I found this apex class that does what I need it to and wrote the trigger which works great in the sandbox. However, I'm at a complete loss as to how I would even start writing a test class for this. Please help!
trigger convertNumbersToWords on Grant__c (before Insert, Before Update) { 
   NumberTOWordConvertion ntoWord = new NumberTOWordConvertion();
    For(Grant__c T : trigger.new){
        if(T.Amount__c>0){

         String numbertoWord = ntoWord.getNumberTOWordConvertion(T.Amount__c);
         T.Text_amount__c = numbertoWord;
          
        }
    }
}
 
public class NumberTOWordConvertion {

    // Call this method with Number to convert
    public String getNumberTOWordConvertion(Decimal num) {

        Decimal junkVal = num;
        Decimal junkValCents = junkVal - Math.floor(junkVal);
        junkVal = Math.floor(junkVal);

        String obStr = junkVal.toPlainString();
        String[] numReversed = obStr.split('');
        String[] actnumber = reverse(numReversed);
        String firstHalf = convertInWords(numReversed, actnumber);

        Integer tmp = Math.round(junkValCents * 100);
        junkValCents = (Decimal)tmp / 100; System.debug('jj :' + junkValCents);
        String CentsStr = junkValCents.toPlainString();
        String secondHalf;
        if (CentsStr == '0') {
            secondHalf = '';
        } else if (CentsStr.length() != 4) {
            CentsStr = CentsStr + '0';
            CentsStr = CentsStr.substring(2);
            String [] numReversedCents = CentsStr.split('');
            String[] actnumberCents = reverse(numReversedCents);
            secondHalf = convertInWords(numReversedCents, actnumberCents);
        } else {
            CentsStr = CentsStr.substring(2);
            String [] numReversedCents = CentsStr.split('');
            String[] actnumberCents = reverse(numReversedCents);
            secondHalf = convertInWords(numReversedCents, actnumberCents);
        }

        String SumOFHalves = '';

        if (secondHalf.length() > 4) {
            firstHalf = firstHalf.replace('Only', 'Dollars And ');
            secondHalf = secondHalf.replace('Only', 'Cents Only');
            SumOFHalves = firstHalf + secondHalf;
        } else {
            firstHalf = firstHalf.replace('Only', 'Dollars Only');
            SumOFHalves = firstHalf;
        }

        // IF amount has any value
        if (SumOFHalves.length() > 5) {
            return SumOFHalves;
        } else {
            return '';
        }
    }
    // Method reverse the number
    public List<String> reverse(List<String> strToRev) {
        List<String> revList = new List<String>();
        for (Integer i = strToRev.size() - 1; i >= 0; i--) {
            revList.add(strToRev.get(i));
        }
        revList.add('');
        return revList;
    }

    public String convertInWords(String[] numRev, String[] actnum) {
        List<String> iWords = new List<String> {'Zero', ' One', ' Two', ' Three', ' Four', ' Five', ' Six', ' Seven', ' Eight', ' Nine'};
        List<String> ePlace = new List<String> {' Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'};
        List<String> tensPlace = new List<String> {'dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' };

        Integer iWordsLength = numRev.size();
        String totalWords = '';
        List<String> inWords = new List<String>();
        for (Integer k = 0; k < iWordsLength; k++) {
            inWords.add('');
        }
        String finalWord = '';
        Integer j = 0;

        // Main For loop
        for (Integer i = 0; i < iWordsLength; i++) {

            if (i == 0) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Only';
            } else if (i == 1) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }
            } else if (i == 2) {
                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i - 1] != '0' && actnum[i - 2] != '0') {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred and';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred';
                }
            } else if (i == 3) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Thousand';
                }
            } else if (i == 4) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 5) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Hundred Thousand';
                }
            } else if (i == 6) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 7) {
                if (actnum[i] == '0' || actnum[i + 1] == '1' ) {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Ten Million';
            } else if (i == 8) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            }

            j++;
        }
        // End of For loop

        // Reverse the List
        inWords = reverse(inWords);

        for (Integer i = 0; i < inWords.size(); i++) {
            finalWord += inWords[i];
        }

        return finalWord;
    }


}

 
Hi,

Can someone help me change the font size for this page block title?
<div style="float: left; width: 100%;"> 
<apex:pageBlock title="Household Members">
   <apex:pageBlockTable value="{!Intake__c.Household_Members_CCA__r}" var="HM">
   <apex:column >
   <apex:facet name="header">Name</apex:facet>
      <apex:outputField value="{!HM.Household_Member_Name__c}"/>
      </apex:column>
      <apex:column >
   <apex:facet name="header">Relationship</apex:facet>
      <apex:outputField value="{!HM.Relationship_to_Head_of_Household__c}"/>
      </apex:column>
     <apex:column >
   <apex:facet name="header">Birthdate</apex:facet>
    <apex:outputField value="{!HM.Birthdate__c}"/>   
      </apex:column>
        <apex:column >
   <apex:facet name="header">Gender</apex:facet>
    <apex:outputField value="{!HM.Gender__c}"/>   
      </apex:column>
       <apex:column >
      <apex:facet name="header">Race and Ethnicity</apex:facet>
    <apex:outputField value="{!HM.Race__c}"/>,&nbsp; <apex:outputField value="{!HM.Ethnicity__c}"/>   
      </apex:column>
       </apex:pageBlockTable>
</apex:pageBlock>
</div>

 
Hi, I've got the first half of this working correctly. I want only records in the apex:repeat where a number field (age__c) is over 17. I also want only records where a picklist field (status__c) value is 'current.' I'm stumped how to add this second filter onto the records.

How do I write this with two filters on the apex repeat? 
<apex:page standardController="Account" tabStyle="Account" docType="html" renderas="pdf">
<html>
<apex:styleSheet value="{!URLFOR($Resource.AHHClientReportingCSS)}" />
    <div>
        <table>
            <tr>
                <td style="width:245px;height:85px;">
                    <apex:image url="/resource/SPHousing" width="100%"/>                    
                </td>
                <td style="font-weight:bold;font-size:22px;text-align:center;">
                    3-DAY NOTICE TO PAY RENT OR MOVE OUT
                </td>
            </tr>
        </table>
    </div>
    <div class="outerSpace">
    </div>
    <td style="font-weight:bold;font-size:16px;text-align:left;">
    
    Plaintiff(s): SP Housing Resources<br></br>
    <br></br>
    </td>
    <div style="float: left; width: 50%;">  
    Defendant(s):<br/> 
    <apex:repeat value="{!Account.Households__r}" var="house">
    <apex:outputPanel rendered="{!house.Age__c > 17}">
        <apex:outputField value="{!house.Household_Member__c}"/>, Resident<br></br>
        <br></br>  
         </apex:outputPanel>  
    </apex:repeat>
    </div>
     <div style="float: right; width: 50%;">
      <td style="font-weight:bold;font-size:18px;text-align:center;">
      Notice to Pay Rent or Quit
      </td>
     </div>
    </html>
    </apex:page>
Hi,

I need help writing a test for the following trigger which submits a record for approval if the created_from_onboarding__c checkbox field is marked true.
trigger autoapprovenewhire on Change_of_statusnew__c (after insert) {
    for(Change_of_statusnew__c changeofstatus : trigger.new){
        if(changeofstatus.created_from_onboarding__c == TRUE){
            // create the new approval request to submit
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Submitted for approval. Please approve.');
            req.setObjectId(changeofstatus.Id);
            // submit the approval request for processing
            Approval.ProcessResult result = Approval.process(req);
            // display if the reqeust was successful
            System.debug('Submitted for approval successfully: '+result.isSuccess());
        }
    }
}
Hi,

I am creating a controller to use in a VF page rendered as a pdf and I'm unable to display cross object formula fields in my controller. The end result is that multiple records that are selected from a list view can be printed as one single document. How can this be achieved or what workaround can I use to make this happen? 
Hi,

I'm in the process of redoing javascript list buttons for lightning. We had a couple buttons that for the selected records, a checkbox field would be marked true which would result in a process builder starting.

I'm trying to use a VF button to do this, but how can I make the value of the checkbox in question marked true so the user just needs to click save for the records he or she has already selected?
<apex:page standardController="Rent_and_Damages__c" recordSetVar="Rent_and_Damages__c">
   <apex:form >
      <apex:pageBlock title="Create Next Month's Rent" mode="edit">
         <apex:pageMessages />
         <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
         </apex:pageBlockButtons>
         <apex:pageBlockTable value="{!selected}" var="rent">
            <apex:column value="{!rent.name}"/>
            <apex:column headerValue="Create Rent">
               <apex:inputField value="{!rent.Create_Rent_for_Next_Month__c}"/>
            </apex:column>
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
</apex:page>

 
Hi, 

I have this code to delete selected records from a List View. While it works fine, it always doubles the number of records that were deleted. Can someone help me to fix the line that tallies up the number of records successfully deleted?
 
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")} 

var records = {!GETRECORDIDS( $ObjectType.Event )}; 
var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; 
records = records.concat(taskRecords); 


if (records[0] == null) { 
alert("Please select at least one record.") } 
else { 

var errors = []; 
var result = sforce.connection.deleteIds(records); 
if (result && result.length){ 
var numFailed = 0; 
var numSucceeded = 0; 
for (var i = 0; i < result.length; i++){ 
var res = result[i]; 
if (res && res.success == 'true'){ 
numSucceeded++; 
} else { 
var es = res.getArray("errors"); 
if (es.length > 0) { 
errors.push(es[0].message); 
} 
numFailed++; 
} 
} 
if (numFailed > 0){ 
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); 
} else { 
alert("Number of records deleted: " + numSucceeded); 
} 
} 
window.location.reload(); 
}

 
Hello,

I'm having trouble getting this VF page to render. The issue is I'm trying to display who created the record, but I get an error every time. The issue is with the  Approved by: <apex:outputField value="!c.Created_by_name__c}"/> section which is a formula field that pulls the user's first and last name who created the record.
<apex:page standardController="Grant__c" 
    recordSetVar="checks" 
    showHeader="false" 
    extensions="GrantCheckPrintController"
    sidebar="false" 
    standardStylesheets="false" 
    renderAs="pdf" 
    applyHtmlTag="false" 
    applyBodyTag="false">
<apex:styleSheet value="{!URLFOR($Resource.checkprinting)}" />
    <apex:repeat value="{! SelectedGrantChecks }" var="c">
    <body>
            <p style="white-space:pre; font-family:Calibri, Gadget, sans-serif;line-height: 14pt;font-size:12px;text-align:left"> 
            Personal ID: &nbsp; <apex:outputfield value="{!c.Personal_ID__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In-House Grant:  &nbsp;<apex:outputfield value="{!c.In_House_Grant__c}"/> &nbsp; &nbsp; 
            Name: &nbsp; <apex:outputfield value="{!c.Clients_Full_Name__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Grant Type:  &nbsp;<apex:outputfield value="{!c.Type_of_Grant__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            Check Number:  &nbsp;<apex:outputField value="{!c.Check_Number__c}"/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Check Date:  &nbsp;<apex:outputfield value="{!c.Date_of_Check__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            Amount:  &nbsp;<apex:outputfield value="{!c.Amount__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Payee:   &nbsp;<apex:outputField value="{!c.Name_to_Appear_on_Check__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
           &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
            </p> Additional Comments:&nbsp;<apex:outputField value="{!c.Additional_Comment_1__c}"/>&nbsp;<apex:outputField value="{!c.Additional_Comment_2__c}"/> &nbsp; Approved by: <apex:outputField value="!c.Created_by_name__c}"/>
         <br></br>
         <br></br>
        <p style="font-family:Calibri, Gadget, sans-serif;font-size:12px;text-align:left">Client Signature:______________________________________________&nbsp;Date:________________________</p>
         <br></br>
         <br></br>
         <br></br>
         <br></br>
         <br></br>       
       <hr size="1">
       </hr> 
        <br></br>
        <br></br>
        <br></br>
        <br></br>
 <p style="white-space:pre; font-family:Calibri, Gadget, sans-serif;line-height: 14pt;font-size:12px;text-align:left"> 
            Personal ID: &nbsp; <apex:outputfield value="{!c.Personal_ID__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In-House Grant:  &nbsp;<apex:outputfield value="{!c.In_House_Grant__c}"/> &nbsp; &nbsp; 
            Name: &nbsp; <apex:outputfield value="{!c.Clients_Full_Name__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Grant Type:  &nbsp;<apex:outputfield value="{!c.Type_of_Grant__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            Check Number:  &nbsp;<apex:outputField value="{!c.Check_Number__c}"/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Check Date:  &nbsp;<apex:outputfield value="{!c.Date_of_Check__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            Amount:  &nbsp;<apex:outputfield value="{!c.Amount__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Payee:   &nbsp;<apex:outputField value="{!c.Name_to_Appear_on_Check__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
           &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
           <br></br>
           </p> Additional Comments:&nbsp;<apex:outputField value="{!c.Additional_Comment_1__c}"/>&nbsp;<apex:outputField value="{!c.Additional_Comment_2__c}"/> 
         <br></br>
       <br></br>
       <br></br>
       <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <br></br>
        <p style="font-family:Calibri, Gadget, sans-serif;font-size:12px;text-align:right"><apex:outputField value="{!c.Check_Number__c}"/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <apex:outputfield value="{!c.Date_of_Check__c}"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp;<apex:outputfield value="{!c.Amount__c}"/></p> 
        <p style="font-family:Calibri, Gadget, sans-serif;font-size:12px;text-align:left">
            <br/>
            <apex:outputfield value="{!c.Text_Amount__c}"/><br/>
            <br/>
            <apex:outputField value="{!c.Name_to_Appear_on_Check__c}"/><br/>
            <br/>
            Memo: &nbsp; <apex:outputField value="{!c.Memo__c}"/></p>
         </body> 
         <div style="page-break-after:always;"/>  
    </apex:repeat>
</apex:page>

 
Hello,

I'm struggling with this. I have 2 custom objects, Invoice for donated goods and donated goods inventory. I want to display a list view from the donated goods inventory on a record for invoice for donated goods. Here's the code I have that keeps giving me an error. 
 
<apex:page standardController="Invoice_for_Donated_Goods__c" showHeader="true"> 
        <apex:enhancedList type="donated_goods_inventory__c" height="300" rowsPerPage="10" id="available_donated_goods" />
</apex:page>

Any help will be appreciated. Thanks!
Hello,

Our process builder page in our production version stopped working the other day. This is the error we get:

alliancehh.lightning.force.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

Clearing cookies and trying different browsers has done nothing. Any suggestions?
Hi,

I'm struggling to get this to work correctly. I have a VF page rendered as a pdf. If there is a phone number extension, it should include that after the phone number. That part of the formula works fine - what I want it to do is if there is an extension to display 'ext.' before it. How would I add that in?
<b>Phone Number:</b>&nbsp;<apex:outputfield value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_s_Phone_Number__c}"/>&nbsp;Ext.<apex:outputField rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c}"/><br></br>

 
I've set up this List View Button to select a certain picklist value for all checked records. Is it possible to create a single List View Button where the user is able to select which picklist value to enter rather than a pre-determined one?
!REQUIRESCRIPT('/soap/ajax/30.0/connection.js')}

try{
    /*
        Getting IDs of all the Selected Records.
    */
    var selectedRecords = {!GETRECORDIDS( $ObjectType.PSH_Check__c )};

    /*
        Ensure that atleast 1 record is selected
    */
    if(selectedRecords.length > 0){
        /*
            Creating an Array to store the Records that 
            are to be Updated.
        */
        var recordsToUpdate = [];

        /*
            Loop thro' each ID and then create a
            record of Type: PSH_Check__c.

            Then assign values to the appropriate Fields
            and finally add it to the recordsToUpdate array.
        */
        for(var i = 0; i < selectedRecords.length; i++){
            var record = new sforce.SObject('PSH_Check__c');

            record.Id = selectedRecords[i];
            record.check_status__c = "Mailed";

            recordsToUpdate.push(record);
        }

        /*
            Update all the records
        */
        var result = sforce.connection.update(recordsToUpdate);

        /*
            Showing the result of the Update
        */
        var message = '';
        var failedCount = 0, successCount = 0;
        for(i = 0; i < result.length; i++){
            if(result[i].getBoolean('success') != true){
                failedCount++;
                message = message + '\n>>' + result[i].errors.message;
            }
            else{
                successCount++;
            }
        }

        alert(
            '::Mass Update Status::\r\n' + 
                'Total Submitted: ' + 
                    (failedCount + successCount) + ' Record(s)\n' +
                'Total Updated: ' + 
                    successCount + ' Record(s)\n' +
                'Failed to Update: ' + 
                    failedCount + ' Record(s)\r\n' +
            message
        );

        /*
            Reload the Page
        */
        location.reload();
    }
    else{
        alert('Please select atleast one row');
    }
}
catch(e){
    alert(
        'An Un-expected Error has Occurred. Error:' +
        e
    );
}

 
Hello,

Can someone point me in the right direction for this:

I have a custom object called PSH_Properties__c, and a checkbox field called Create_Check_1__c. 

I'm trying to create a list button that when records are selected, the Create_Check_1__c checkbox on each record is marked  true. 
Hello,

I'm getting the following error:

Compile Error: Illegal assignment from String to Decimal at line 9 column 38

I've used this code before but always had it related to an account instead of a custom object. I'm stumped on what this means. Any suggestions on how to fix this?
@isTest
public class testProcessPSHRentChange {
    
    public static void createPSHPropertyAndPSHRentChange(integer numOfPSHProperty, integer numOfPSHRentChange){
        
        list<psh_properties__c> aList = new list<psh_properties__c>();
        
        for(integer i = 1; i <= numOfPSHProperty; i++){
            PSH_Properties__c newA = new PSH_Properties__c(
                address__c = '825 Colorado Blvd',
                City__c = 'Los Angeles',
                Zip_Code__c = '90041',
                Rent_Amount__c = '1800.00'  
            );
            aList.add(newA);
        }
    
      insert aList;
        
        list<PSH_Rent_change__c> PSHRentChangeList = new list<psh_rent_change__c>();
        
        for(psh_properties__c a : aList){
            for(integer i = 1; i <= numOfPSHRentChange; i++){
                
                if(i<=12){
                    psh_rent_change__c d = new psh_rent_change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                    
                  PSHRentChangeList.add(d);
                    
                } else {
                    PSH_Rent_Change__c d = new PSH_Rent_Change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                
                    PSHRentChangeList.add(d);
                }
            }
        }
        
        insert PSHRentChangeList;
        
        list<PSH_Rent_Change__c> dCheck = [select id, psh_property__c, status__c, date_of_rent_change__c, rent_amount__c from psh_rent_change__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertNewPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id from psh_properties__c limit 1];
        
        psh_rent_change__c d = new psh_rent_change__c(
          date_of_rent_change__c = date.newInstance(2017, 02, 15),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        psh_rent_change__c dUpdated = [select id, status__c from psh_rent_change__c where date_of_rent_change__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultiplePSHRentChange(){
        
        test.startTest();
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        test.stopTest();
        
        psh_rent_change__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        for(psh_rent_change__c d : a.psh_rent_changes__r){
            
            if(d.id == a.psh_rent_changes__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deletePSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        psh_rent_change__c dToDelete = [select id from psh_rent_change__c where status__c = 'current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(1,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        PSH_Rent_Change__c dToUndelete = [select id from PSH_Rent_Change__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(2,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.psh_rent_changes__r){
                if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updatePSHRentChangeDate(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dList = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : a.PSH_Rent_Changes__r){
            if(d.id == a.PSH_Rent_Changes__r[0].id){
                d.date_of_rent_change__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        psh_properties__c aUpdated = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dListUpdated = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
            
            if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.date_of_rent_change__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testBulkPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(200,10);
        
        list<psh_rent_change__c> dListToModify = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,10,1),d.date_of_rent_change__c);
            psh_rent_change__c dToUpdate = new psh_rent_change__c(
                id = d.id,
              date_of_rent_change__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,9,1),d.date_of_rent_change__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,8,15),d.date_of_rent_change__c);
        }
        
    }

}
Hello,

I have a VF page rendered as a pdf. I have repeat data pulling fields from associated records. What I'd like to do is have a 3 column table where each separate instance of the record populates the row to the right of it. Any suggestions?
Hello,

I'm putting together a Visualforce page to render as a pdf. I am using a repeat function to pull all records in an object related to another record. 

Is it possible to add code into the VF page to list the records in descending order without having to create a controller extension?
I'm struggling to understand this concept.

We have a custom object (Intake__c) that is the master in relationships with other objects (Income__c, Non_Cash_Benefits__c etc.)

I need to be able to create a custom button from an Intake Record that can create a pdf of the Intake Record as well as display fields from records within the related list. Just showing the related list in the pdf does not suffice which is what he currently have.

What is the easiest way to do this? Would I need to create extensions for all the related objects where the id on the Intake Record is the same as the ID on the child records and add them to the standard controller for Intake__c? Then in the VF page layout use an apex:repeat value to displays fields from the multiple records associated to the intake?

If so, could someone help me out with what the basic code for this would look like?

Thanks,

Adam
Hello, I'm getting the above error message in a test class. Stack Trace:
Class.testProcessIncome.createClientAndHouseholdAndIncome: line 58, column 1
Class.testProcessIncome.testBulkIncome: line 211, column 1
 
@isTest
public class testProcessIncome {
    
    public static void createClientAndHouseholdAndIncome (integer numofClients, integer numOfHousehold, integer numOfIncome){
        
        list<account> aList = new list<account>();
        
        for(integer i = 1; i <= numOfClients; i++){
            account newA = new account(
                firstname = 'Test',
                lastname = 'Client',
                social_security_number__c = '000-00-0000',
                personBirthdate = date.newInstance(1980, 1, 1),
                gender__c = 'Female',
                ethnicity__c = 'Client refused',
                language__c = 'English',
                hiv_status__c = 'AIDS',
                secondary_disability__c = 'No Secondary Disability'
            );
            aList.add(newA);
        }
     
      insert aList;
        
        list<household_member__c> HouseholdList = new list<household_member__c>();
        
        for(account a : aList){
            for(integer i = 1; i <= numOfHousehold; i++){
                
                if(i<=12){
                    household_member__c h = new household_member__c(
                        status__c = 'Current',
                        household__c = a.id
                    );                    
                  HouseholdList.add(h);
                    
                } else {
                    household_member__c h = new household_member__c(
                        status__c = 'Current',
                        household__c = a.id
                    );                
                    HouseholdList.add(h);
                }
            }
        }
        
        insert HouseholdList;
        
        list<household_member__c> hCheck = [select id, household__c, status__c from household_member__c];
        system.debug(hCheck);
        
        list<income__c> IncomeList = new list<income__c>();
        
        for(household_member__c h : HouseholdList){
            for(account a : aList){
                for(integer i = 1; i <= numOfIncome; i++){
                    if(i<=12){
                        income__c d = new income__c(
                            start_of_pay_period__c = date.newInstance(2017, i, 1),
                            Household_Member__c = h.id,
                            Client__c = a.id
                        );                    
                      IncomeList.add(d);
                        
                    } else {
                        income__c d = new income__c(
                            start_of_pay_period__c = date.newInstance(2017, 1, 1),
                            household_member__c = h.id,
                            Client__c = a.id
                        );                
                        IncomeList.add(d);
                    }
                }
            }
         }
        
        insert IncomeList;
        
        list<income__c> dCheck = [select id, household_member__c, client__c, status__c, start_of_pay_period__c from income__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertincome(){
        
        createClientAndHouseholdandIncome(1,2,3);
        
        account a = [select id from account limit 1];
        household_member__c h = [select id from household_member__c limit 1];
        
        income__c d = new income__c(
          start_of_pay_period__c = date.newInstance(2017, 02, 15),
          household_member__c = h.id,
          client__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        income__c dUpdated = [select id, status__c, client__c from income__c where start_of_pay_period__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultipleIncome(){
        
        test.startTest();
        
        createClientAndHouseholdAndIncome(1,2,3);
        
        test.stopTest();
        
        household_member__c h = [select id, (select id, status__c, client__c, start_of_pay_period__c from Incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        for(income__c d : h.incomes__r){
            
            if(d.id == h.incomes__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deleteIncome(){
        
        createClientAndHouseholdAndIncome(1,2,3);
        
        household_member__c h = [select id, (select id, status__c, client__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dListToDelete = new list<income__c>();
        
        income__c dToDelete = [select id from income__c where status__c = 'Current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(household_member__c hUpdated : [select id, (select id, status__c, client__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c where id = :h.id]){
            system.assertEquals(0,hUpdated.incomes__r.size());
            for(income__c d : hUpdated.incomes__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        income__c dToUndelete = [select id from income__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(household_member__c hUpdated : [select id, (select id, status__c, client__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c where id = :h.id]){
            system.assertEquals(0,hUpdated.incomes__r.size());
            for(income__c d : hUpdated.incomes__r){
                if(d.id == hUpdated.incomes__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updateIncomeDate(){
        
        createClientAndHouseholdAndIncome(1,2,3);
        
        household_member__c h = [select id, (select id, status__c, client__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dList = new list<income__c>();
        
        for(income__c d : h.incomes__r){
            if(d.id == h.incomes__r[0].id){
                d.start_of_pay_period__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        household_member__c hUpdated = [select id, (select id, status__c, client__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dListUpdated = new list<income__c>();
        
        for(income__c d : hUpdated.incomes__r){
            
            if(d.id == hUpdated.incomes__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.start_of_pay_period__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testBulkIncome(){
        
        createClientAndHouseholdAndIncome(200,10,10);
        
        list<income__c> dListToModify = new list<income__c>();
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,10,1),d.start_of_pay_period__c);
            income__c dToUpdate = new income__c(
                id = d.id,
              start_of_pay_period__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<income__c> dListToDelete = new list<income__c>();
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,9,1),d.start_of_pay_period__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,8,15),d.start_of_pay_period__c);
        }
        
    }

}

Any suggestions on how to fix?
Hello,

I'm having trouble figuring out the lookup fields in a test class. There is a custom object called Houshold_Member__c. Another custom object called Income__c has a lookup field to it. Household__c is a master-detail relationship to a person account. 

@isTest
public class testProcessIncome {
    
    public static void createHouseholdAndIncome (integer numOfHousehold, integer numOfIncome){
        
        list<Household_Member__c> HouseholdList = new list<Household_Member__c>();
        
        for(integer i = 1; i <= numOfHousehold; i++){
            Household_member__c newA = new Household_member__c(
            Household__c = ??????
            Household_Member__c = ????
            Status__c = 'Current'
            );
            householdList.add(newA);
        }
    
      insert householdList;
        
        list<income__c> IncomeList = new list<income__c>();
        
        for(household_member__c a : householdList){
            for(integer i = 1; i <= numOfIncome; i++){
                
                if(i<=12){
                    income__c d = new income__c(
                        start_of_pay_period__c = date.newInstance(2017, i, 1),
                        Household_Member__c = a.id
                    );                    
                  IncomeList.add(d);
                    
                } else {
                    income__c d = new income__c(
                        start_of_pay_period__c = date.newInstance(2017, 1, 1),
                        household_member__c = a.id
                    );                
                    IncomeList.add(d);
                }
            }
        }
        
        insert IncomeList;
        
        list<income__c> dCheck = [select id, household_member__c, status__c, start_of_pay_period__c from income__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertincome(){
        
        createHouseholdandIncome(1,2);
        
        household_member__c a = [select id from household_member__c limit 1];
        
        income__c d = new income__c(
          start_of_pay_period__c = date.newInstance(2017, 02, 15),
          household_member__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        income__c dUpdated = [select id, status__c from income__c where start_of_pay_period__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultipleIncome(){
        
        test.startTest();
        
        createHouseholdAndIncome(1,2);
        
        test.stopTest();
        
        household_member__c a = [select id, (select id, status__c, start_of_pay_period__c from Incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        for(income__c d : a.incomes__r){
            
            if(d.id == a.incomes__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deleteIncome(){
        
        createHouseholdAndIncome(1,2);
        
        household_member__c a = [select id, (select id, status__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dListToDelete = new list<income__c>();
        
        income__c dToDelete = [select id from income__c where status__c = 'Current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(household_member__c aUpdated : [select id, (select id, status__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c where id = :a.id]){
            system.assertEquals(1,aUpdated.incomes__r.size());
            for(income__c d : aUpdated.incomes__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        income__c dToUndelete = [select id from income__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(household_member__c aUpdated : [select id, (select id, status__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c where id = :a.id]){
            system.assertEquals(2,aUpdated.incomes__r.size());
            for(income__c d : aUpdated.incomes__r){
                if(d.id == aUpdated.incomes__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updateIncomeDate(){
        
        createHouseholdAndIncome(1,2);
        
        household_member__c a = [select id, (select id, status__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dList = new list<income__c>();
        
        for(income__c d : a.incomes__r){
            if(d.id == a.incomes__r[0].id){
                d.start_of_pay_period__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        household_member__c aUpdated = [select id, (select id, status__c, start_of_pay_period__c from incomes__r order by start_of_pay_period__c desc, createddate desc) from household_member__c limit 1];
        
        list<income__c> dListUpdated = new list<income__c>();
        
        for(income__c d : aUpdated.incomes__r){
            
            if(d.id == aUpdated.incomes__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.start_of_pay_period__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testIncome(){
        
        createHouseholdAndIncome(200,10);
        
        list<income__c> dListToModify = new list<income__c>();
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,10,1),d.start_of_pay_period__c);
            income__c dToUpdate = new income__c(
                id = d.id,
              start_of_pay_period__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<income__c> dListToDelete = new list<income__c>();
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,9,1),d.start_of_pay_period__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(income__c d : [select id, start_of_pay_period__c, status__c from income__c where status__c = 'Current']){
            system.assertEquals(date.newInstance(2017,8,15),d.start_of_pay_period__c);
        }
        
    }

}


Hi,

I found this apex class that does what I need it to and wrote the trigger which works great in the sandbox. However, I'm at a complete loss as to how I would even start writing a test class for this. Please help!
trigger convertNumbersToWords on Grant__c (before Insert, Before Update) { 
   NumberTOWordConvertion ntoWord = new NumberTOWordConvertion();
    For(Grant__c T : trigger.new){
        if(T.Amount__c>0){

         String numbertoWord = ntoWord.getNumberTOWordConvertion(T.Amount__c);
         T.Text_amount__c = numbertoWord;
          
        }
    }
}
 
public class NumberTOWordConvertion {

    // Call this method with Number to convert
    public String getNumberTOWordConvertion(Decimal num) {

        Decimal junkVal = num;
        Decimal junkValCents = junkVal - Math.floor(junkVal);
        junkVal = Math.floor(junkVal);

        String obStr = junkVal.toPlainString();
        String[] numReversed = obStr.split('');
        String[] actnumber = reverse(numReversed);
        String firstHalf = convertInWords(numReversed, actnumber);

        Integer tmp = Math.round(junkValCents * 100);
        junkValCents = (Decimal)tmp / 100; System.debug('jj :' + junkValCents);
        String CentsStr = junkValCents.toPlainString();
        String secondHalf;
        if (CentsStr == '0') {
            secondHalf = '';
        } else if (CentsStr.length() != 4) {
            CentsStr = CentsStr + '0';
            CentsStr = CentsStr.substring(2);
            String [] numReversedCents = CentsStr.split('');
            String[] actnumberCents = reverse(numReversedCents);
            secondHalf = convertInWords(numReversedCents, actnumberCents);
        } else {
            CentsStr = CentsStr.substring(2);
            String [] numReversedCents = CentsStr.split('');
            String[] actnumberCents = reverse(numReversedCents);
            secondHalf = convertInWords(numReversedCents, actnumberCents);
        }

        String SumOFHalves = '';

        if (secondHalf.length() > 4) {
            firstHalf = firstHalf.replace('Only', 'Dollars And ');
            secondHalf = secondHalf.replace('Only', 'Cents Only');
            SumOFHalves = firstHalf + secondHalf;
        } else {
            firstHalf = firstHalf.replace('Only', 'Dollars Only');
            SumOFHalves = firstHalf;
        }

        // IF amount has any value
        if (SumOFHalves.length() > 5) {
            return SumOFHalves;
        } else {
            return '';
        }
    }
    // Method reverse the number
    public List<String> reverse(List<String> strToRev) {
        List<String> revList = new List<String>();
        for (Integer i = strToRev.size() - 1; i >= 0; i--) {
            revList.add(strToRev.get(i));
        }
        revList.add('');
        return revList;
    }

    public String convertInWords(String[] numRev, String[] actnum) {
        List<String> iWords = new List<String> {'Zero', ' One', ' Two', ' Three', ' Four', ' Five', ' Six', ' Seven', ' Eight', ' Nine'};
        List<String> ePlace = new List<String> {' Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'};
        List<String> tensPlace = new List<String> {'dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' };

        Integer iWordsLength = numRev.size();
        String totalWords = '';
        List<String> inWords = new List<String>();
        for (Integer k = 0; k < iWordsLength; k++) {
            inWords.add('');
        }
        String finalWord = '';
        Integer j = 0;

        // Main For loop
        for (Integer i = 0; i < iWordsLength; i++) {

            if (i == 0) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Only';
            } else if (i == 1) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }
            } else if (i == 2) {
                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i - 1] != '0' && actnum[i - 2] != '0') {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred and';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])] + ' Hundred';
                }
            } else if (i == 3) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Thousand';
                }
            } else if (i == 4) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 5) {
                if (actnum[i] == '0' || actnum[i + 1] == '1') {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                if (actnum[i + 1] != '0' || Integer.valueof(actnum[i]) > 0) {
                    inWords[j] = inWords[j] + ' Hundred Thousand';
                }
            } else if (i == 6) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            } else if (i == 7) {
                if (actnum[i] == '0' || actnum[i + 1] == '1' ) {
                    inWords[j] = '';
                } else {
                    inWords[j] = iWords[Integer.valueof(actnum[i])];
                }
                inWords[j] = inWords[j] + ' Ten Million';
            } else if (i == 8) {

                if (actnum[i] == '0') {
                    inWords[j] = '';
                } else if (actnum[i] == '1') {
                    inWords[j] = ePlace[Integer.valueof(actnum[i - 1])];
                } else {
                    inWords[j] = tensPlace[Integer.valueof(actnum[i])];
                }

            }

            j++;
        }
        // End of For loop

        // Reverse the List
        inWords = reverse(inWords);

        for (Integer i = 0; i < inWords.size(); i++) {
            finalWord += inWords[i];
        }

        return finalWord;
    }


}

 
Hi,

Can someone help me change the font size for this page block title?
<div style="float: left; width: 100%;"> 
<apex:pageBlock title="Household Members">
   <apex:pageBlockTable value="{!Intake__c.Household_Members_CCA__r}" var="HM">
   <apex:column >
   <apex:facet name="header">Name</apex:facet>
      <apex:outputField value="{!HM.Household_Member_Name__c}"/>
      </apex:column>
      <apex:column >
   <apex:facet name="header">Relationship</apex:facet>
      <apex:outputField value="{!HM.Relationship_to_Head_of_Household__c}"/>
      </apex:column>
     <apex:column >
   <apex:facet name="header">Birthdate</apex:facet>
    <apex:outputField value="{!HM.Birthdate__c}"/>   
      </apex:column>
        <apex:column >
   <apex:facet name="header">Gender</apex:facet>
    <apex:outputField value="{!HM.Gender__c}"/>   
      </apex:column>
       <apex:column >
      <apex:facet name="header">Race and Ethnicity</apex:facet>
    <apex:outputField value="{!HM.Race__c}"/>,&nbsp; <apex:outputField value="{!HM.Ethnicity__c}"/>   
      </apex:column>
       </apex:pageBlockTable>
</apex:pageBlock>
</div>

 
Hi,

I need help writing a test for the following trigger which submits a record for approval if the created_from_onboarding__c checkbox field is marked true.
trigger autoapprovenewhire on Change_of_statusnew__c (after insert) {
    for(Change_of_statusnew__c changeofstatus : trigger.new){
        if(changeofstatus.created_from_onboarding__c == TRUE){
            // create the new approval request to submit
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Submitted for approval. Please approve.');
            req.setObjectId(changeofstatus.Id);
            // submit the approval request for processing
            Approval.ProcessResult result = Approval.process(req);
            // display if the reqeust was successful
            System.debug('Submitted for approval successfully: '+result.isSuccess());
        }
    }
}
Hello,

I'm struggling with this. I have 2 custom objects, Invoice for donated goods and donated goods inventory. I want to display a list view from the donated goods inventory on a record for invoice for donated goods. Here's the code I have that keeps giving me an error. 
 
<apex:page standardController="Invoice_for_Donated_Goods__c" showHeader="true"> 
        <apex:enhancedList type="donated_goods_inventory__c" height="300" rowsPerPage="10" id="available_donated_goods" />
</apex:page>

Any help will be appreciated. Thanks!
Hi,

I'm struggling to get this to work correctly. I have a VF page rendered as a pdf. If there is a phone number extension, it should include that after the phone number. That part of the formula works fine - what I want it to do is if there is an extension to display 'ext.' before it. How would I add that in?
<b>Phone Number:</b>&nbsp;<apex:outputfield value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_s_Phone_Number__c}"/>&nbsp;Ext.<apex:outputField rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c}"/><br></br>

 
Hello,

I'm getting the following error:

Compile Error: Illegal assignment from String to Decimal at line 9 column 38

I've used this code before but always had it related to an account instead of a custom object. I'm stumped on what this means. Any suggestions on how to fix this?
@isTest
public class testProcessPSHRentChange {
    
    public static void createPSHPropertyAndPSHRentChange(integer numOfPSHProperty, integer numOfPSHRentChange){
        
        list<psh_properties__c> aList = new list<psh_properties__c>();
        
        for(integer i = 1; i <= numOfPSHProperty; i++){
            PSH_Properties__c newA = new PSH_Properties__c(
                address__c = '825 Colorado Blvd',
                City__c = 'Los Angeles',
                Zip_Code__c = '90041',
                Rent_Amount__c = '1800.00'  
            );
            aList.add(newA);
        }
    
      insert aList;
        
        list<PSH_Rent_change__c> PSHRentChangeList = new list<psh_rent_change__c>();
        
        for(psh_properties__c a : aList){
            for(integer i = 1; i <= numOfPSHRentChange; i++){
                
                if(i<=12){
                    psh_rent_change__c d = new psh_rent_change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                    
                  PSHRentChangeList.add(d);
                    
                } else {
                    PSH_Rent_Change__c d = new PSH_Rent_Change__c(
                        Date_of_rent_change__c = date.newInstance(2017, i, 1),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
                    );                
                    PSHRentChangeList.add(d);
                }
            }
        }
        
        insert PSHRentChangeList;
        
        list<PSH_Rent_Change__c> dCheck = [select id, psh_property__c, status__c, date_of_rent_change__c, rent_amount__c from psh_rent_change__c];
        system.debug(dCheck);
        
  }
    
    public static testMethod void insertNewPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id from psh_properties__c limit 1];
        
        psh_rent_change__c d = new psh_rent_change__c(
          date_of_rent_change__c = date.newInstance(2017, 02, 15),
                        Rent_Amount__c = '1800.00',
                        psh_property__c = a.id
        );
        
        test.startTest();
        
        insert d;
        
        test.stopTest();
        
        psh_rent_change__c dUpdated = [select id, status__c from psh_rent_change__c where date_of_rent_change__c = 2017-02-15];
        
        system.assertEquals('Current',dUpdated.status__c);
        
    }
    
    public static testMethod void insertMultiplePSHRentChange(){
        
        test.startTest();
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        test.stopTest();
        
        psh_rent_change__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        for(psh_rent_change__c d : a.psh_rent_changes__r){
            
            if(d.id == a.psh_rent_changes__r[0].id){
                system.assertEquals('Current',d.status__c);
            } else {
                system.assertEquals('Past',d.status__c);
            }
            
        }
        
    }
    
    public static testMethod void deletePSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_changes__r order by date_of_rent_change__c desc, createddate desc) from account limit 1];
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        psh_rent_change__c dToDelete = [select id from psh_rent_change__c where status__c = 'current' limit 1];
        
        test.startTest();
        
        delete dToDelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(1,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
                system.assertEquals('Current',d.status__c);
            }
        }
        
        PSH_Rent_Change__c dToUndelete = [select id from PSH_Rent_Change__c where isdeleted = true limit 1 ALL ROWS];
        
        undelete dToUndelete;
        
        for(psh_properties__c aUpdated : [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c where id = :a.id]){
            system.assertEquals(2,aUpdated.PSH_Rent_Changes__r.size());
            for(psh_rent_change__c d : aUpdated.psh_rent_changes__r){
                if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                  system.assertEquals('Current',d.status__c);
                } else {
                    system.assertEquals('Past',d.status__c);
                }
            }
        }
        
        test.stopTest();
        
    }
    
    public static testMethod void updatePSHRentChangeDate(){
        
        createPSHPropertyAndPSHRentChange(1,2);
        
        psh_properties__c a = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dList = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : a.PSH_Rent_Changes__r){
            if(d.id == a.PSH_Rent_Changes__r[0].id){
                d.date_of_rent_change__c = date.newInstance(2016,12,1);
                dList.add(d);
            }
        }
        
        test.startTest();
        
        checkRecursive.reset();
        update dList;
        
        test.stopTest();
        
        psh_properties__c aUpdated = [select id, (select id, status__c, date_of_rent_change__c from PSH_Rent_Changes__r order by date_of_rent_change__c desc, createddate desc) from psh_properties__c limit 1];
        
        list<psh_rent_change__c> dListUpdated = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : aUpdated.PSH_Rent_Changes__r){
            
            if(d.id == aUpdated.PSH_Rent_Changes__r[0].id){
                system.assertEquals('Current',d.Status__c);
                system.assertEquals(date.newInstance(2017,1,1),d.date_of_rent_change__c);
            } else {
                system.assertEquals('Past',d.Status__c);
            }
        }
        
    }
    
    public static testMethod void testBulkPSHRentChange(){
        
        createPSHPropertyAndPSHRentChange(200,10);
        
        list<psh_rent_change__c> dListToModify = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,10,1),d.date_of_rent_change__c);
            psh_rent_change__c dToUpdate = new psh_rent_change__c(
                id = d.id,
              date_of_rent_change__c = date.newInstance(2017,8,15)
            );
            dListToModify.add(dToUpdate);
        }
        
        checkRecursive.reset();
        update dListToModify;
        
        list<psh_rent_change__c> dListToDelete = new list<psh_rent_change__c>();
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,9,1),d.date_of_rent_change__c);
            dListToDelete.add(d);
        }
        
        delete dListToDelete;
        
        for(psh_rent_change__c d : [select id, date_of_rent_change__c, status__c from psh_rent_change__c where status__c = 'current']){
            system.assertEquals(date.newInstance(2017,8,15),d.date_of_rent_change__c);
        }
        
    }

}
I'm struggling to understand this concept.

We have a custom object (Intake__c) that is the master in relationships with other objects (Income__c, Non_Cash_Benefits__c etc.)

I need to be able to create a custom button from an Intake Record that can create a pdf of the Intake Record as well as display fields from records within the related list. Just showing the related list in the pdf does not suffice which is what he currently have.

What is the easiest way to do this? Would I need to create extensions for all the related objects where the id on the Intake Record is the same as the ID on the child records and add them to the standard controller for Intake__c? Then in the VF page layout use an apex:repeat value to displays fields from the multiple records associated to the intake?

If so, could someone help me out with what the basic code for this would look like?

Thanks,

Adam
Hi,
I am trying to create a formula field that concatenates a text field and a date field. Is there anyway around this?

Status__c &" - "& StatusActionDate__c


Thanks,
Alex
Hello,

I'm new to working on Visualforce pages.

We have an object that if a checkbox field is marked as true by the user, there is a formula field that returns a line of text if true, null if false. An example of one of these formulas is:

IF( Household_Budget_does_not_Show_a_Need__c , "Household budget does not show a need for the level of assistance requested", null)

I have it set to treat blank fields as blank.

There are about 21 of these fields. The problem I'm having with the Visualforce page is that when the field is null, it's still leaving a line of space on the pdf. What I would like is if the value is null, there will be no line of space.

Currently on the Visualforce page, I have it set up like:<apex:outputfield value="{!Application_Update__c.Household_Budget_Text__c}"/> 

How can I display this field that if it's null it will not take up a line of space on the Visualforce page?
Hi there,

I have a formula to track crisis bed nights accessed by clients. The formula returns a value on bed nights at the start date and stops counting when an end date is added. The formula returns a numerical value.

VALUE(TEXT(IF(NOT(ISBLANK( Date_of_Exit__c)),  Date_of_Exit__c  -  Date_of_Entry__c ,  TODAY()  -  Date_of_Entry__c )))

I want to add this value into a roll-up summary on the client's account to show how many nights within a six month period have been used, however, the field is not an option. How can I get this work?.