You need to sign in to do that
Don't have an account?
Jaanu
Trigger Code Issue .. Help me pls
I am trying to call the class from trigger... getting the error 'Method does not exist or incorrect signature: void acctphoneupdate(List<Account>) from the type AccClass1'. Pls help in resolving this issue.
I have the following Class
public class AccClass1 {
public static acctphoneupdate(List<Account> Acc) {
// list<Account> Acct = [Select Phone from Account];
// for ( Account Acc : Acct) {
if (Acc.phone == '4001002000')
{
Acc.phone = '4040404040';
insert Acc;
}
// }
}
}
I have the trigger as below:
trigger Acctrigger1 on Account (before insert) {
AccClass1 first = new AccClass1();
first.acctphoneupdate(Trigger.new); <--- This is the line of code having issue.
}
I have the following Class
public class AccClass1 {
public static acctphoneupdate(List<Account> Acc) {
// list<Account> Acct = [Select Phone from Account];
// for ( Account Acc : Acct) {
if (Acc.phone == '4001002000')
{
Acc.phone = '4040404040';
insert Acc;
}
// }
}
}
I have the trigger as below:
trigger Acctrigger1 on Account (before insert) {
AccClass1 first = new AccClass1();
first.acctphoneupdate(Trigger.new); <--- This is the line of code having issue.
}
All Answers
AccClass1.acctphoneupdate() ;
Please use the code below:-
public class AccClass1 {
public static void acctphoneupdate(List<Account> Acct) {
for ( Account Acc : Acct) {
if (Acc.phone == '4001002000') {
Acc.phone = '4040404040';
}
}
}
}
..........................................................
trigger Acctrigger1 on Account (before insert) {
AccClass1.acctphoneupdate(Trigger.new);
}
Inside your code please use return type for the method and second you should call all static things via class name. Always remember you can call static things(Methods or variable) with in a class directly but if you gonna call any static things (Methods or variable) from another class just use class name e.g. ClassName.Method_Name();
or
Classname.variable_name;
If you get your solution please mark it as Solved or you may select it as best answere.
Happy Coding :)
Thanks & Regards,
Deepak
public class AccClass1 {
public static void acctphoneupdate(Account Acc) {
if (Acc.phone == '4001002000')
{
Acc.phone = '4040404040';
Insert Acc;
}
}
}
trigger Acctrigger1 on Account (before insert) {
AccClass1.acctphoneupdate(Trigger.new); ---> Error Message "Method does not exist or incorrect signature: void acctphoneupdate(List<Account>) from the type AccClass1"
}
What is wrong with the above code pls ?
Apex Class like below
Let us know if this will help you
Thanks . Can you pls provide the code. thanks.
Change public static acctphoneupdate(List<Account> Acct)