• Harry Johnson
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
HI All,

We are currently trying to populate a field on the opportunity based the opportunity having multiple tasks within which certain criteria are fulfilled.

The idea is: if more than one task has a certain field filled, we need a field on the opp to take that value.

The problem is: the field on each task, from which we need to take the value, could have a few different values across the tasks, and there will be more than one task on each opportunity. The field on each task will be a lookup.

We only want the opportunity field to be populated when two or more tasks have the same values in the field.

Does anyone have any ideas as to how this could be done? Thanks in advance for any help.
Hi Everyone,

When creating an opportunity via lead conversion, I am trying to set the opportunity Primary Campaign Source field as a campaign entered on the lead, with a trigger.

My code is: 
 
trigger UpdatePCS on Lead (after update) {

if (trigger.old[0].isConverted == false && trigger.new[0].isConverted == true)

    if (Trigger.new[0].ConvertedOpportunityId != null) {
    
        Opportunity opp = [SELECT Id FROM Opportunity WHERE Id = :Trigger.new[0].ConvertedOpportunityId];
        opp.CampaignId = trigger.old[0].Primary_Campaign_Source__c;
        
        }
        
    }

No errors, but it fails to fill in the Primary Campaign Source with anything at all. I have tried a few variations, all resulting in errors.

If anyone can help me it would be great, this is my first trigger, and im a little lost..

Thanks.
Hi Everyone,

When creating an opportunity via lead conversion, I am trying to set the opportunity Primary Campaign Source field as a campaign entered on the lead, with a trigger.

My code is: 
 
trigger UpdatePCS on Lead (after update) {

if (trigger.old[0].isConverted == false && trigger.new[0].isConverted == true)

    if (Trigger.new[0].ConvertedOpportunityId != null) {
    
        Opportunity opp = [SELECT Id FROM Opportunity WHERE Id = :Trigger.new[0].ConvertedOpportunityId];
        opp.CampaignId = trigger.old[0].Primary_Campaign_Source__c;
        
        }
        
    }

No errors, but it fails to fill in the Primary Campaign Source with anything at all. I have tried a few variations, all resulting in errors.

If anyone can help me it would be great, this is my first trigger, and im a little lost..

Thanks.