• Shawna.ax1585
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

I'm trying to update a field located on the contact record of contacts  referenced on the contact roles related list of opportunities.  (So I want to select contacts that are tied to a specific opportunity)

I'm receiving the below error on my trigger. Can someone help?  Is this possible to do?

 

 

Error: Compile Error: Nesting of semi join sub-selects is not supported

 

 

Contact[] contactsNetNewWon = [SELECT Id, Net_New_Won_Survey_Needed__c
FROM Contact
WHERE Active_Contact__c = true
AND Id IN
(SELECT ContactID
FROM OpportunityContactRole
WHERE OpportunityID IN
(SELECT Id FROM Opportunity
WHERE Id IN :oppsNetNewWon))];

I am trying to write a formula that says, if the "One Year from original contract date" field is less than today then display the green flag; otherwise display the red flag.

 

The One year original contract date field is a date formula field (Original_Start_Date__c + 365). 

 

This is what I've written so far but it's not working.  Can someone help me?

 

IMAGE (
IF ( One_Year_from_Original_Contract_Date__c < TODAY()),"/img/samples/flag_green.gif",
"/img/samples/flag_red.gif" )

I'm trying to pull the Managers NAME (not ID) of the opportunity owner and display it on the opportunity record.  I was able to do this by copying the below trigger someone else had posted.  It works great but I want the manager "time stamped" meaning, I don't want the managers name to be updated if it happens to change.  I only want the field to display the manager of the opp owner at the time the opp was created. 

 

How can I do this??

********************************************************

 

trigger UpdateOwnerManager on Opportunity (before insert, before update ){
  /**
  1. For each opportunity being inserted add User Id value in in Set of User Ids.
  2. Fetch all Users whose Id is in the Set.
  3. Add these fetched Users in a Map <User Id, User object>
  4. for each opportunity being inserted get User from the map and update the field values  
  **/  
 
  //holds User Ids
  Set<Id> setUserIds = new Set<Id>();
 
  //holds a list of Users
  List<User> lstUser = new List<User>();
 
  //holds key value pairs of User Id and User Object
  Map<Id, User> mapUserObj = new Map<Id, User>();

  //holds User object
  User UserObj;
   
  //For each opportunity being inserted add User Id value in in Set of User Ids.
  for(Opportunity oppObj : Trigger.new){
    if(oppObj.OwnerId != null){
      setUserIds.add(oppObj.OwnerId);
    }
  }
 
  //Fetch all Users whose Id is in the Set.
  lstUser = [select Id, Name, ManagerId from User where Id in :setUserIds Limit 1000];
  if(lstUser.size() == 0){
    return;  
  }
 
  //Add these fetched Users in a Map <User Id, User object>
  for(User usrObj : lstUser){
    mapUserObj.put(usrObj.Id, usrObj);  
  }
 
  //for each opportunity being inserted get User from the map and update the field values
  for(Opportunity oppObj : Trigger.new){
    //get User object
    if(oppObj.OwnerId != null){
      if(mapUserObj.containsKey(oppObj.OwnerId)){
        UserObj = mapUserObj.get(oppObj.OwnerId);
        //map opportunity fields to User fields
        oppObj.Opportunity_Owner_s_Manager__c = UserObj.ManagerId;
      }  
    }
  }
}

 

I am trying to write a formula that says, if the "One Year from original contract date" field is less than today then display the green flag; otherwise display the red flag.

 

The One year original contract date field is a date formula field (Original_Start_Date__c + 365). 

 

This is what I've written so far but it's not working.  Can someone help me?

 

IMAGE (
IF ( One_Year_from_Original_Contract_Date__c < TODAY()),"/img/samples/flag_green.gif",
"/img/samples/flag_red.gif" )

Hi,

 

Is there a way to identify if an opportunity is converted from lead or not in apex?

 

Thanks