• Community User2
  • NEWBIE
  • 35 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hey everyone,

I received a request to remove the chatter alerts on accounts that say "[NAME] updated this account by converting a lead." I'm sure you've received that complaint before as well, since those alerts can't be removed via the admin setup.

User-added image

So I tried creating a trigger to delete those alerts when a lead is converted, but I get an error that says I can't filter by the FeedItem's "Body" field, which as far as I know, is the only way to distinguish these types of alerts. Here is the trigger I tried writing:

public class ClassDeleteConvertAlerts{
    
    public void deleteAlerts(List<Lead> leads,Map<Id,Lead> oldLeads){
        
        Set<String> convertedLeads = new Set<String>();
        List<FeedItem> feedItemsToDelete = new List<FeedItem>();
        
        FOR(Lead l : leads){
            IF(l.IsConverted == TRUE && oldLeads.get(l.Id).IsConverted == FALSE){
                convertedLeads.add(l.Id);
            }
        }
        
        IF(convertedLeads.size() > 0){
            FOR(FeedItem item : [SELECT
                                   Id,Title
                               	 FROM
                                   FeedItem
                                 WHERE
                                   Body LIKE '%updated this account by converting a lead%']){

                                                       feedItemsToDelete.add(item);

                                                  }
        					                                  
         IF(feedItemsToDelete.size() > 0){
            DELETE feedItemsToDelete;
        }
        
    }

}

Is there any way to accomplish what I'm trying to do? Can I delete feeditems based on what's in the Body?

Thanks!
-Greg
I need to update the field values from opportunityLineItem to Contract.Need to aggregate opptyLineItem field values from all opptylineItem and then update it on Contract.we have a custom lookup to Contract from Opportunity.I am having difficulty in pulling all related opptylineitems field values of each contract in trigger.

User-added image

public class OpportunityLineItemTriggerHandler {

 public void OnAfterInsert(OpportunityLineItem[] newOpptyLine){

  updateContractFields(newOpptyLine);

 }


 public void updateContractFields(OpportunityLineItem[] newOpptyLine){

 set<Id>conIds = new set<Id>();
 list<Id>oliIds = new list<Id>();
 list<Id>pbeIds = new list<Id>();
 list<OpportunityLineItem> oliList = new list<OpportunityLineItem>();
 list<PricebookEntry> pbeList = new list<PricebookEntry>();
 list<Contract> conList = new list<Contract>();
 list<Opportunity> oppList = new list<Opportunity>();
 map<Id,Id> oliConMap = new map<Id,Id>();


 Date startDate = date.newinstance(Date.Today().Year(), 1, 1);
 Date endDate = date.newinstance(Date.Today().Year(),12, 31);

 for(OpportunityLineItem oli : newOpptyLine){

     oliIds.add(oli.Id);

   }

 pbeList = [Select p.Product2.Family, p.Product2.Id, p.Product2Id, p.Id, (Select Id, OpportunityId, Quantity, TotalPrice, ServiceDate From OpportunityLineItems) From PricebookEntry p where p.Product2.Family = 'Regular tags'];

 for(PricebookEntry pbe : pbeList){
    pbeIds.add(pbe.Id);
 }

map<Id,OpportunityLineItem> oliMap = new map<Id,OpportunityLineItem>([Select o.TotalPrice, o.ServiceDate, o.Quantity, o.PricebookEntry.ProductCode, o.PricebookEntry.Product2Id, o.PricebookEntryId, o.Opportunity.Contract__c,o.Opportunity.Contract__r.Current_Contract_Year_End__c, o.Opportunity.Contract__r.Current_Contract_Year_Start__c, o.Opportunity.Contract__r.Contract_Year_Tags_Purchased__c,o.OpportunityId, o.Id From OpportunityLineItem o where o.Id in:oliIds and o.PricebookEntryId in: pbeIds ]); 

 for(OpportunityLineItem oli : oliMap.values()){
     conIds.add(oli.Opportunity.Contract__c);
     oliConMap.put(oli.Id,oli.Opportunity.Contract__c);
    }


  map<Id,Contract> conMap = new map<Id,Contract>([Select c.Id, c.Current_Contract_Year_Start__c, c.Current_Contract_Year_End__c, c.Contract_Year_Tags_Purchased__c,c.Fiscal_Year_Tags_Purchased__c,c.Total_Tags_Purchased__c,(Select Id From Opportunities_del__r) From Contract c where Id in :conIds]);


  for(Contract con : conMap.values()){

     for(Opportunity o:con.Opportunities_del__r){

        for(OpportunityLineItem oli :o.OpportunityLineItems){

         if(oliMap.containsKey(oli.Id)) {

           if(oli.ServiceDate > con.Current_Contract_Year_Start__c &&  oli.ServiceDate < con.Current_Contract_Year_End__c){

                 con.Contract_Year_Tags_Purchased__c = con.Contract_Year_Tags_Purchased__c + oli.Quantity;

             }

               if(oli.ServiceDate > startDate && oli.ServiceDate < endDate){
                  con.Fiscal_Year_Tags_Purchased__c  = con.Fiscal_Year_Tags_Purchased__c  + oli.Quantity;
                  }
            }
        }

     }

  }

  update conMap.values();

 }

}


I need complete functionality of chatter in visualforce page.Just like below image.How to achieve this

ge.User-added image
I need complete functionality of chatter in visualforce page.Just like below image.How to achieve this

ge.User-added image
Hey everyone,

I received a request to remove the chatter alerts on accounts that say "[NAME] updated this account by converting a lead." I'm sure you've received that complaint before as well, since those alerts can't be removed via the admin setup.

User-added image

So I tried creating a trigger to delete those alerts when a lead is converted, but I get an error that says I can't filter by the FeedItem's "Body" field, which as far as I know, is the only way to distinguish these types of alerts. Here is the trigger I tried writing:

public class ClassDeleteConvertAlerts{
    
    public void deleteAlerts(List<Lead> leads,Map<Id,Lead> oldLeads){
        
        Set<String> convertedLeads = new Set<String>();
        List<FeedItem> feedItemsToDelete = new List<FeedItem>();
        
        FOR(Lead l : leads){
            IF(l.IsConverted == TRUE && oldLeads.get(l.Id).IsConverted == FALSE){
                convertedLeads.add(l.Id);
            }
        }
        
        IF(convertedLeads.size() > 0){
            FOR(FeedItem item : [SELECT
                                   Id,Title
                               	 FROM
                                   FeedItem
                                 WHERE
                                   Body LIKE '%updated this account by converting a lead%']){

                                                       feedItemsToDelete.add(item);

                                                  }
        					                                  
         IF(feedItemsToDelete.size() > 0){
            DELETE feedItemsToDelete;
        }
        
    }

}

Is there any way to accomplish what I'm trying to do? Can I delete feeditems based on what's in the Body?

Thanks!
-Greg

Hi everyone,

 

I want to change the look-and-feel of the default Chatter page.  Basically, I want to apply my own CSS, make minor layout adjustments, and hide the default salesforce menu at the top.  Does anyone know how I can do this?  Is it possible to get the VisualForce code for that page somehow to allow me to make the modifications?  I don't want to rewrite a custom Chatter page from scratch, since I'd be reusing the existing functionality and page layout as is.

 

Any help is appreciated!  Many thanks!