Skip to main content
deleted 48 characters in body
Source Link

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can I achieve it? Basically I have created a custom object which has a lookup on the opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month. Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) {
Set<id>ids=new set<id>();
list<opportunity>oplst=new list<opportunity>();
    For(Monthly_Sales_Target__c trg:trigger.new){
        if(trg.Opportunities__c!=Null){
            ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c
  }
    }
    
if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can I achieve it? Basically I have created a custom object which has a lookup on the opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month. Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) {
Set<id>ids=new set<id>();
list<opportunity>oplst=new list<opportunity>();
    For(Monthly_Sales_Target__c trg:trigger.new){
        if(trg.Opportunities__c!=Null){
            ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c
  }
    }
    
if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can I achieve it? Basically I have created a custom object which has a lookup on the opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month. Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) {
Set<id>ids=new set<id>();
list<opportunity>oplst=new list<opportunity>();
    For(Monthly_Sales_Target__c trg:trigger.new){
        if(trg.Opportunities__c!=Null){
            ids.add(trg.Opportunities__c); 
    }
    
if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}
added 43 characters in body
Source Link
Rahul Gawale
  • 12.3k
  • 6
  • 33
  • 70

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can iI achieve it? Basically iI have created a custom object which has a lookup on the opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month.Opportunity Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) { Setids=new set(); listoplst=new list(); For(Monthly_Sales_Target__c trg:trigger.new){ if(trg.Opportunities__c!=Null){ ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c } }

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) {
Set<id>ids=new set<id>();
list<opportunity>oplst=new list<opportunity>();
    For(Monthly_Sales_Target__c trg:trigger.new){
        if(trg.Opportunities__c!=Null){
            ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c
  }
    }
    
if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can i achieve it? Basically i have created a custom object which has a lookup on opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month.Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) { Setids=new set(); listoplst=new list(); For(Monthly_Sales_Target__c trg:trigger.new){ if(trg.Opportunities__c!=Null){ ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c } }

if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can I achieve it? Basically I have created a custom object which has a lookup on the opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month. Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) {
Set<id>ids=new set<id>();
list<opportunity>oplst=new list<opportunity>();
    For(Monthly_Sales_Target__c trg:trigger.new){
        if(trg.Opportunities__c!=Null){
            ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c
  }
    }
    
if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}
Source Link

Trigger Error on Custom Object and Opportunity

I want the following trigger to compare opportunity close date month with the custom date field month (Monthly Sales Target and Year). How can i achieve it? Basically i have created a custom object which has a lookup on opportunity and I want the lookup field to be auto-updated in the opportunity and Custom object should pull out all related opportunities based on the criteria Closed date month.Opportunity = month in the Custom Object. Can you please guide me.

trigger TriggeronTarget on Monthly_Sales_Target__c (before insert, before update) { Setids=new set(); listoplst=new list(); For(Monthly_Sales_Target__c trg:trigger.new){ if(trg.Opportunities__c!=Null){ ids.add(trg.Opportunities__c); //lookup field to opportunity on bid__c } }

if(!ids.Isempty())
{
    list<opportunity >opp =[select id,name,closeDate from opportunity where Budget_Month__c= Null AND id in:ids ];     
       for(opportunity op:opp){
  
for(Monthly_Sales_Target__c trg1: trigger.new){
            op.Budget_Month__c =trg1.id;
            oplst.add(op);
}
    }
    update oplst;
}  
}