You need to sign in to do that
Don't have an account?
Scapelli77
Eclipse & Trigger
Hi,i have just develope my first trigger, bu i cannot deploy it in to Unlimited Edition, why?
When i try to deploy the trigger, Eclipse failure the coverage test...
this is my trigger:
trigger PaymentTerm on Opportunity (before insert, before update) {
Opportunity[] MyOp = Trigger.new;
for (Opportunity p:MyOp){
if (p.Description != 'World') {
p.Description = 'World';
}
}
}
thanks
Simone
Examples are in the Apex docs under the Testing and Code Coverage section, page 214.
when you run tests on this class it also tests your trigger
Thanks,
with your code i can deploy my trigger.... but is very necessary a class if my trigger don't need a class?
Now I have an other problem, this is my trigger:
trigger PaymentTerm on Opportunity (before insert, before update) {
Opportunity[] MyOp = Trigger.new;
for (Opportunity p:MyOp){
if (p.PaymentTerm__c == null) {
p.PaymentTerm__c=[select Terms_of_Payment__c from Account where Id = :p.AccountId];
}
}
}
would look something like this
p.PaymentTerm__c=[select Terms_of_Payment__c from Account where Id = .AccountId limit 1].Terms_of_Payment__c;
Note, your trigger will bread if bulk loading of opportunities is run as it will hit DML limits since it makes a query for each record. There are a few posts and articles on Bulk processing, please review these for a general solution.