• Gtennent
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Here's what I'm trying to do. I work for a small nonprofit and I want to create a button that auto-generates a pdf thank you message for staff to print out and mail. Easy enough. I also want staff to be able to update and edit the text of that thank you, without having to learn to code, using pre-defined code pieces in their document. For instance, I want them to be able to write "Thank you for your {!Opportunity.Amount} gift..." and have it show up as "Thank you for your $50 gift..."

Here's my process so far: I put a long text/field on the campaign object where staff person can paste the letter text. Then in Visualforce, I call up this text field and display it. So far so good, kinda. 

My issue is that in the text of the Visualforce page it still says "Thank you for your {!Opportunity.Amount} gift...". If I use <apex:outputField ... /> instead it does the samething. It isn't displaying the information from the opportunity. If I put {!Opportunity.Amount} directly in my visualforce page it works just fine.

Here's the code for that section. Changing the escape doesn't help. 
<apex:outputText escape="false" value="{!Opportunity.Campaign.Ack_Letter_Text__c}"/>





Two questions:
  1. How can I put field values or apex code into a text field, and have it display properly when called in a Visualforce page?
  2. If the answer to 1 is no, then can you suggest a workaround that would make it easy for non-dev staff to update or create new letter copy?
I'm trying to create a visualforce page rendered as a PDF so staff can easily print out or email specific documents that automatically tailor to the account. I want to put the documents on our letterhead but I'm having trouble getting it the proper size. I can set the background image of the page, but I can't seem to change its size. I've uploaded the image and style sheet as a static resource. The style is as follows.
@Page{
     size: 8.5in 11in;     
     background-image:url('LetterheadJPG.jpg');
     background-size: 8.5in 11in;
}

No matter what I put in for background-size nothing changes. How can I get the background (letterhead) to fit to the size of the page? Also, if I use body{} instead of @page, the background doesn't load at all.

Is there a better way to input the letterhead into the document?
I'm using the Nonprofit Starter Pack and I would like a way for volunteer hours to displace on household(account) pages as well as the contact page. I have already added an account lookup field, because I can't use Master-Detail. I think those have already been used for the contact and the volunteer job. So now I'm trying to create a trigger that updates the Total Hours field on the account, which is a sum of the hours field on the volunteer hour object. My question is how do I write code to sum those hours for the correct? Here's where I am thus far.
trigger RollupVolunteerHours on Volunteer_Hours__c (After insert, after update, after delete) {
	Set<Id> AccountIds = new Set<Id>();
    list<Volunteer_Hours__c> vHours = [SELECT Id, Hours__c FROM Volunteer_Hours__c WHERE Id IN :trigger.new];
    for(Volunteer_Hours__c vh :trigger.new){
        AccountIds.add(vh.Account__r.Id);
    }
	
    list<Account> acctList = [SELECT Id, Total_Hours__c FROM Account WHERE Id IN :AccountIDs];
    
    For(Account acct : acctList){
        //acct.Total_Hours__c = Summation of Volunteer_Hours__r.Hours__c
        
        update acct;
    }
}

Am I on the right track? How do I use what I have to do what I want? If something is unnecessary, why? Same for missing. I'm fairly new to apex so please explain steps instead of giving me code. I want to learn and understand!

Thanks!

I'm trying to complete the Bulk Apex Triggers challenge. I understand what needs to be done, but I don't know how to do it. Also, I'm getting the very helpful error "Executing against the trigger does not work as expected."

The directions are:
  • To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.
  • The Apex trigger must be called 'ClosedOpportunityTrigger'
  • With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
  • To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
  • This challenge specifically tests 200 records in one operation.
Here's my code:
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
    List<Task> newTasks = new List<Task>();
    
    for(Opportunity opp : [SELECT Id, Name, StageName FROM Opportunity WHERE StageName = 'Closed Won' AND Id in :Trigger.new]){
    	newTasks.add(new Task(Subject = 'Follow Up Test Task.',
                             WhatId = opp.Id));
    }
    If(newTasks.size() > 0){
        insert newTasks;
    }    

}
Where have I gone wrong, why is it wrong, and how can I fix it? Please don't just give me code that works that doesn't helpe me learn. I want to understand why the code works, and how to get there from where I am. Thanks!
I'm trying to complete the "Getting Started with Apex Unit Tests" module on the trailhead. I got to the challenge and created the test class. I did as it says and did an "All Run" then went to complete the challenge, but I got an error back. I checked to see what tests were run and the class I created doesn't show up. I go to "New Run" and it doesn't show up. I saved the class then closed and reopened the tab only to find this:
public class TestVerifyDate{

}

I retyped my code, saved it (ctrl +c and File > save), copied it, and repeat the steps above. Same thing. When I open the code it comes up blank. Luckily I copied it so I can paste it back in. I closed and reopened the DC window. The tab remembers what I typed, but if I close and reopen it gets wiped. I have logged out and back in; all to no avail. So long story short, what is going on? Why won't my class save anything other than the basic starting info? 

Here's a sample of the code. All of the tests repeat the same format so I won't copy them for the sake of brevity.
 
@isTest
private class TestVerifyDate {

    @isTest static void dateTest11(){
        Date date11 = VerifyDate.CheckDates(07/18/2016, 07/29/2016);
        System.assertEquals(07/29/2016, date11);
    }

//Repeat other tests below. All brackets are closed, all semi-colons are present.
//This follows the TemeratureConverterTest example test class format shown in the module,
//Only changes are variables, methods, etc.

}


 
Here's what I'm trying to do. I work for a small nonprofit and I want to create a button that auto-generates a pdf thank you message for staff to print out and mail. Easy enough. I also want staff to be able to update and edit the text of that thank you, without having to learn to code, using pre-defined code pieces in their document. For instance, I want them to be able to write "Thank you for your {!Opportunity.Amount} gift..." and have it show up as "Thank you for your $50 gift..."

Here's my process so far: I put a long text/field on the campaign object where staff person can paste the letter text. Then in Visualforce, I call up this text field and display it. So far so good, kinda. 

My issue is that in the text of the Visualforce page it still says "Thank you for your {!Opportunity.Amount} gift...". If I use <apex:outputField ... /> instead it does the samething. It isn't displaying the information from the opportunity. If I put {!Opportunity.Amount} directly in my visualforce page it works just fine.

Here's the code for that section. Changing the escape doesn't help. 
<apex:outputText escape="false" value="{!Opportunity.Campaign.Ack_Letter_Text__c}"/>





Two questions:
  1. How can I put field values or apex code into a text field, and have it display properly when called in a Visualforce page?
  2. If the answer to 1 is no, then can you suggest a workaround that would make it easy for non-dev staff to update or create new letter copy?
I'm trying to complete the "Getting Started with Apex Unit Tests" module on the trailhead. I got to the challenge and created the test class. I did as it says and did an "All Run" then went to complete the challenge, but I got an error back. I checked to see what tests were run and the class I created doesn't show up. I go to "New Run" and it doesn't show up. I saved the class then closed and reopened the tab only to find this:
public class TestVerifyDate{

}

I retyped my code, saved it (ctrl +c and File > save), copied it, and repeat the steps above. Same thing. When I open the code it comes up blank. Luckily I copied it so I can paste it back in. I closed and reopened the DC window. The tab remembers what I typed, but if I close and reopen it gets wiped. I have logged out and back in; all to no avail. So long story short, what is going on? Why won't my class save anything other than the basic starting info? 

Here's a sample of the code. All of the tests repeat the same format so I won't copy them for the sake of brevity.
 
@isTest
private class TestVerifyDate {

    @isTest static void dateTest11(){
        Date date11 = VerifyDate.CheckDates(07/18/2016, 07/29/2016);
        System.assertEquals(07/29/2016, date11);
    }

//Repeat other tests below. All brackets are closed, all semi-colons are present.
//This follows the TemeratureConverterTest example test class format shown in the module,
//Only changes are variables, methods, etc.

}