Archives: 2008 October

Salesforce, Salesforce, Salesforce

October 27th, 2008, 2 Comments

I’m in Boston for the week attending the Salesforce.com DEV-501 Visualforce, Apex and DaasS training class. It should be an interesting week as I arrive back home late Saturday night and then fly out again the next morning bright and early for Dreamforce in San Francisco for 4 days.
Will be tough to get an actual [...]

How to Unit Test Sending Mail in Apex

October 15th, 2008, 3 Comments

I ran into an issue the other day where I wanted to send out an email notification as part of a trigger. The code itself was no problem but, like most days, my problems began as I tried to write the unit test. I couldn’t get the required test coverage on those lines of code.
<rant>Please [...]

Attaching a Document to a Record in Salesforce.com (Java)

October 10th, 2008, No Comments

The follow code allows you to upload a physical file to Salesforce.com and attach it to a record.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/** 
 * See the following:
 * API Docs: http://www.salesforce.com/us/developer/docs/sforce70/wwhelp/wwhimpl/js/html/wwhelp.htmhref=sforce_API_objects_Attachment.html
 * Example: http://community.salesforce.com/sforce/board/messageboard.id=JAVA_development&message.id=4223
 */
 
try {
 
    File f = new File("c:\java\test.docx");
    InputStream is = new FileInputStream(f);
    byte[] inbuff = new byte[(int)f.length()];        
    is.read(inbuff);
 
    Attachment attach = new Attachment();
    attach.setBody(inbuff);
    attach.setName("test.docx");
    attach.setIsPrivate(false);
    // attach to [...]

Feed

http://blog.jeffdouglas.com / 2008 October