function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mahimahi 

regarding api call from trigger

hi,
 
can we call an api function inside trigger?
 
for eg. i create a class and use api calls there and call that class inside trigger.
 
please help me out.
 
thanks,
mahi
tschatztschatz

Are you asking if you can call a class from a trigger?

If so, then yes. If not, please explain what you are asking in greater detail.

Code:

trigger myTrigger on Opportunity (before insert, before update) {
 Opportunity[] opps = Trigger.new;
 myClass.myMethod(opps);
}


 

mahimahi
suppose i put following code in apex , then i got an error  message SingleEmailMessage doesnot exist.

 messages[0] = new SingleEmailMessage(); 
   messages[0].setBccAddresses(new String[] {"jdoe@acme.com", "jdoe@merce.com" });
   messages[0].setCcAddresses(new String[] {"jdoe@gmail.com", "jdoe@salesforce.com" } );
   messages[0].setBccSender(true);
   messages[0].setEmailPriority(EmailPriority.High);
   messages[0].setReplyTo("dcarroll@salesforce.com");
   messages[0].setSaveAsActivity(true);
   messages[0].setSubject("This is how you use the sendEmail call.");

so i am not able to figure out what is the problem?

thanks,

mahi

Ron HessRon Hess
try this:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();


from page 131, of the doc (it's cool to read the doc, really)

i have this in the top of my bookmarks

http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf