Skip to main content
12 events
when toggle format what by license comment
Aug 14, 2013 at 19:20 vote accept Richard N
Aug 14, 2013 at 19:20 comment added Richard N I forgot to update this...I finally ended up creating a VF page and a button which has access to getContent() and that worked for us...but for most other requirements, the solution given by Phil should work too so I will mark this as the solution.
Jul 23, 2013 at 14:48 comment added Phil Hawthorn Yes, it will do from a Scheduled job - you need to pass it in as part of the initial state as per the post I refer to in my previous comment and ensure that your session doesn't expire before the scheduled job runs.
Jul 23, 2013 at 14:33 comment added Richard N Hi Phil, I did try this before as well and tried again a lot yesterday....UserInfo.getsession() returns blank! I created a VF page and added a button and that worked fine...Not fully automated but it will need to do for now.
Jul 22, 2013 at 19:51 comment added Phil Hawthorn I think you are only missing this from your request: request.setHeader('Authorization', 'OAuth ' + sessionId); but as per this post salesforce.stackexchange.com/questions/14042/… you'll need to make sure you pass the session id in
Jul 22, 2013 at 19:37 comment added Richard N Yeah good times :) I have issues no what which approach...I tried hard to look at an example of making a GET request by passing a SF user/password but did not find out. The 302 response shows that it wants be to pass in authentication information as well.
Jul 22, 2013 at 19:28 comment added Phil Hawthorn You could try using a workflow 'field update' to auto-populate the email field on the object that you're sending. Failing that, I would have thought a trigger to auto populate it would be less code than what you're trying to do with the callout (which btw, might be failing because you're not authenticating your web service call)
Jul 22, 2013 at 19:18 comment added Richard N Yes Phil. You are right. It looks like the email recipient needs to be present on an email field on the object which uses the workflow So I can't access the email fields on the Accounts...rats!
Jul 22, 2013 at 18:52 comment added Phil Hawthorn The downside is that you'd have to have some reference to a Contact on the Invoice__c record. You could also try a field type of 'Email Field' on the Invoice (but I think it has to be on the Invoice) but I'm not sure how the recipientType in the email template would behave with that. I haven't time to test it i'm afraid, but it definitely works with a Contact lookup.
Jul 22, 2013 at 18:42 comment added Richard N Thanks so much Phil. It looks like this could work. The only thing is that the recipient email comes from a field on the Account object(Every customer has one account and one field containing this email). Is there any way I can access that field here and set it as the To: address?Thanks!
Jul 22, 2013 at 18:28 history edited Phil Hawthorn CC BY-SA 3.0
added 10 characters in body
Jul 22, 2013 at 18:11 history answered Phil Hawthorn CC BY-SA 3.0