+ Start a Discussion
Sales Force FRMSales Force FRM 

How to call a class from trigger

    Hi Folks,
                   I need to call a  class from trigger , the class  takes a parameter and create the account!

Regards,
Rajeshwar.
jrotensteinjrotenstein
Hi Rajeshwar,

Can you please provide more details about what you are trying to do? It isn't clear from your original message.

For example, are you writing a Trigger? Are you trying to create an Account record?
Sales Force FRMSales Force FRM
Hi John,
             I have a class which will create a account by passing account name as parameter in the method  and now i need to call this class from trigger my class is as follows:
public class InsertAccount{


public static String createAccount(String accName){

String createdAccounts='';
String message='';
String firstName='rajeshwar';
String secondName='Suhel Ahmed';
Integer count=0;
try {
count=[select count() from account where name like : (firstName)];
if(count>0){
message='The Account \' '+firstName+'\' already in use!';
}else{
Account first = new Account();
first.name=firstName;
first.type='prospect';
Account[] accs = new Account[]{first};
// Attempt to insert it...
insert accs;
message='The Account \' '+firstName+'\' created Successfully!';
}



} catch (ListException e) {
// But will get here
}
return message;
}

}
Now i need to call
createAccount(String accName)  method from trigger, how can call this method from trigger!

Thanks,
Rajeshwar.