You need to sign in to do that
Don't have an account?
Alejandro Ortega Asun
how to call a class method in a trigger
Hi!
I'm blocked in an Apex field update in Case object.
On the one hand, I have a class that have 2 decimal variables that must have values depending on case fields:
Apex Class
public class HelloWorld{
public static decimal helloWorld2(){
decimal x;
decimal y;
case c = new Case;
if(c.CustomField1__c == 'A'){x = 1}else{x=0}
if(c.CustomField2__c == 'B'){y = 1}else{y=0}
c.CustomField3__c = x+y;
}
}
On the other hand, I have a trigger that calls the class method:
Trigger
trigger CaseTrigger on Case (before insert, before update, after insert) {
if (Trigger.isBefore) {
if (Trigger.isInsert) {
HelloWorld.helloWorld2( Trigger.new );
}}}
With this code I have an error like "Method does not exist or incorrect signature: void helloWorld2(List<Case>) from the type HelloWorld"
I'm new in Apex and I will be appreciated if someone can give any help.
Regards,
Alex.
I'm blocked in an Apex field update in Case object.
On the one hand, I have a class that have 2 decimal variables that must have values depending on case fields:
Apex Class
public class HelloWorld{
public static decimal helloWorld2(){
decimal x;
decimal y;
case c = new Case;
if(c.CustomField1__c == 'A'){x = 1}else{x=0}
if(c.CustomField2__c == 'B'){y = 1}else{y=0}
c.CustomField3__c = x+y;
}
}
On the other hand, I have a trigger that calls the class method:
Trigger
trigger CaseTrigger on Case (before insert, before update, after insert) {
if (Trigger.isBefore) {
if (Trigger.isInsert) {
HelloWorld.helloWorld2( Trigger.new );
}}}
With this code I have an error like "Method does not exist or incorrect signature: void helloWorld2(List<Case>) from the type HelloWorld"
I'm new in Apex and I will be appreciated if someone can give any help.
Regards,
Alex.
And use this trigger
All Answers
Apex CLass
But there is no any calculous in "CustomField3__c", the field before inserting a new case is empty
And use this trigger
Regards,