You need to sign in to do that
Don't have an account?
Update Trigger
I have a trigger that updates opportunity amount based on a field from a custom object (Proposal). I need to modify this trigger to only perform this field update if custom field Apttus_Proposal__Primary__c (checkbox) is checked. Can someone please help me with where in this trigger I need to define this?
Trigger updteopp_Amount on Apttus_Proposal__Proposal__c (after update, after insert) {
Map<id,Decimal> varmap=new Map<id,Decimal>();
List<Opportunity> opp=new List<Opportunity>();
if(Trigger.isupdate){
for(Apttus_Proposal__Proposal__c App:Trigger.New){
if(Trigger.NewMap.get(App.id).Total_Quote_Amount_2__c!=null ){
varmap.put(App.Apttus_Proposal__Opportunity__c,App.Total_Quote_Amount_2__c); //Apttus_Proposal__Opportunity__c put ur lookup which is onto opportunity
}
}
if(!varmap.IsEMpty()){
List<Opportunity> opps=[select id,name,Amount from opportunity where id in:Varmap.keyset()];
if(!opps.isEmpty()){
for(Opportunity o:opps){
o.Amount=varmap.get(o.id);
opp.add(o);
}
database.update(opp);
}
}
}
}
You can try adding "&& App.Apttus_Proposal__Primary__c == true" (see green font).
Trigger updteopp_Amount on Apttus_Proposal__Proposal__c (after update, after insert) {
Map<id,Decimal> varmap=new Map<id,Decimal>();
List<Opportunity> opp=new List<Opportunity>();
if(Trigger.isupdate){
for(Apttus_Proposal__Proposal__c App:Trigger.New){
if(Trigger.NewMap.get(App.id).Total_Quote_Amount_2__c!=null && App.Apttus_Proposal__Primary__c == true ){
varmap.put(App.Apttus_Proposal__Opportunity__c,App.Total_Quote_Amount_2__c); //Apttus_Proposal__Opportunity__c put ur lookup which is onto opportunity
}
All Answers
You can try adding "&& App.Apttus_Proposal__Primary__c == true" (see green font).
Trigger updteopp_Amount on Apttus_Proposal__Proposal__c (after update, after insert) {
Map<id,Decimal> varmap=new Map<id,Decimal>();
List<Opportunity> opp=new List<Opportunity>();
if(Trigger.isupdate){
for(Apttus_Proposal__Proposal__c App:Trigger.New){
if(Trigger.NewMap.get(App.id).Total_Quote_Amount_2__c!=null && App.Apttus_Proposal__Primary__c == true ){
varmap.put(App.Apttus_Proposal__Opportunity__c,App.Total_Quote_Amount_2__c); //Apttus_Proposal__Opportunity__c put ur lookup which is onto opportunity
}
Thanks, that did the trick! I wasn't sure where to add that extra logic. Thanks so much.