You need to sign in to do that
Don't have an account?
rajesh kumar 50
Doubt on Trigger
Below is my trigger:
trigger opportunityinsertupdate on opportunity(before insert,before update) {
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o : trigger.new) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) /*&& (o.Super_Region__c == 'Asia/India')*/) {
o.stagename = 'Sales Lead';
o.amount = 1;
o.CurrencyIsoCode = 'USD';
o.Target_ShipDate__c = o.Target_ShipDate__c.addmonths(3);
flag = false;
}
}
}
if(trigger.isUpdate && flag) {
for(opportunity o1:trigger.new){
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) /*&& o1.Super_Region__c == 'Asia/India' */&& o1.Check__c == false) {
o1.stagename = 'Sales Lead';
o1.amount = 1;
o1.CurrencyIsoCode = 'USD';
o1.Target_ShipDate__c = o1.Target_ShipDate__c.addmonths(3);
o1.Check__c = true;
}
}
}
}
BUt the main problem is super_region__c field in on account object and based on that field also the trigger have to fired..
here in my code i have commented super_region__c field but i want to take that field from account object.
so can any one suggest me how to solve this problem.
thanks in advance.
trigger opportunityinsertupdate on opportunity(before insert,before update) {
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o : trigger.new) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) /*&& (o.Super_Region__c == 'Asia/India')*/) {
o.stagename = 'Sales Lead';
o.amount = 1;
o.CurrencyIsoCode = 'USD';
o.Target_ShipDate__c = o.Target_ShipDate__c.addmonths(3);
flag = false;
}
}
}
if(trigger.isUpdate && flag) {
for(opportunity o1:trigger.new){
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) /*&& o1.Super_Region__c == 'Asia/India' */&& o1.Check__c == false) {
o1.stagename = 'Sales Lead';
o1.amount = 1;
o1.CurrencyIsoCode = 'USD';
o1.Target_ShipDate__c = o1.Target_ShipDate__c.addmonths(3);
o1.Check__c = true;
}
}
}
}
BUt the main problem is super_region__c field in on account object and based on that field also the trigger have to fired..
here in my code i have commented super_region__c field but i want to take that field from account object.
so can any one suggest me how to solve this problem.
thanks in advance.
Can you please try the below code,
I believe you are trying to get the associated Account record's field "super_region__c" from the opportunity.
If that is the case you cannot get the lookup recods field through this.
1: You need to first get the account id associated with the opportunity
2: Next get the query the Account with that field "super_region__c"
3: Next do your existing logic what yoou have written.
Hope that helps you.
Regards