You need to sign in to do that
Don't have an account?

Webservice to email to my personal email address
All,
I need to develop a webservice, which will be called in a trigger after some field update. This webservice should send the email to my personal email address. Could someone guide me with the steps required to complete this mini-project?
Thanks!!!
Couldn't you just create a workflow rule to send an email to your address...?
Thanks for your reply again SfdcFox.
Actually the requirement I have is: when a field, which is a picklist field, in SFDC is changed to something else than an existing value, for example a current option in the stage of Opportunity is changed from Awareness to Prospect, then a trigger is fired in Salesforce which calls an external webservice and SFDC also needs to send an email informing that the call of the external webservice worked.
Is there any code snippets I can refer to understand and begin to deliver the requirement.
Our goal is to call an external service as the change occurs and to send an email confirmation that informs that the goal was achieved without an error. How should I approach this problem? Can I do this without using trigger at all?
Thanks!!!
So far what I am thinking is, I have an after update trigger ready which will execute the callout future method as well as send the Opportunity Id and updated stage name to the external webservice. I am hoping I am heading into right direction
Now I have couple of questions. To test if the opportunity Id and Updated stage name were actually passed, is there any test endpoint available to be used in req.setBody = ...... so that I can see it for myself that the id and updated stage name were passed properly.
And also, how do I embed an email within it which will notify an inbox saying the job of sending the infos to callout was done?
Will really appreciate any insights!!
Thanks thanks!!
Once you get the response of the request messages you sent in the future calls, you can then check the response to see if you got a successful status and based on this you can send emails using apex. Use the messaging.singleEmailMessage class to help you out.
Keep in mind that callouts are not supported in triggers at this time, since a callout could cause a potentially long row-level lock. Instead, you have to use an asynchronous callout from your trigger. The asynchronous code can report the error in a custom field on the record, which will become available to the user after the callout has completed. bob_buzzard posted in one forum reply to note that you can perform callouts in a Visualforce page, so you might be able to use that method instead. Assuming you use the asynchronous call from a trigger, you can have that function send an email as part of its logic.
for (Integer i = 0; i < Trigger.new.size(); i++) {
if (Trigger.new[i].UpsellOpportunity__c != Trigger.old[i].UpsellOpportunity__c) {
WebServiceCallout.sendNotification(acc.Id, acc.Name, acc.UpsellOpportunity__c);
}
}
}
}
Your code may run into governor limits (e.g. 10 future methods per transaction) on data loads, but you might not be able to help that; I'd say that you might need to use a batch class to send larger amounts of callouts. Other than that, it looks well. As for sending XML, there are XML classes for reading and writing XML documents in memory, so you should look at the docs.