• Catie
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

Hi, 

I am looking to send trigger a chatter alert in a group when an opportunity is changed to Closed Won. We are currently using email alerts (AND( ISCHANGED(StageName), Probability = 1, NOT(Owner.Id = "005d0000001TUC8")) but would like to move the interaction to chatter: 

 

Below is my attempt but

 

1. When I try this I get the error - Compile Error: unexpected token: insert at line 26 column 8 

2.As it is in the workflow - I would like to have one person's opportunitiy's (NOT(Owner.Id = 005d0000001TUC8) not trigger this workflow for privacy reasons

 

Could anyone help me clean this up? Thank you so much!

 

trigger ChatterWonOpportunity on Opportunity (after insert, after update) {

String status;
String OppAccName;
//Decimal OppAmount;
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(Trigger.isInsert) {
                               if(o.IsWon == true && Trigger.oldMap.get(o.id).IsWon == false) {
                    for (Opportunity oppty : [SELECT Account.Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                    }
                   o.owner +' just won' + OppAccName + 'for' o.expectedrevenue + ‘!';
                    }
                    else {
                        return;
                    }
                }
            
            post.ParentId = //0F9K000000005LR
            post.Title = o.Name;
            post.Body = status;
            }
        }
        insert post;
    }
}

 

  • August 06, 2013
  • Like
  • 0

Hi, 

I am looking to send trigger a chatter alert in a group when an opportunity is changed to Closed Won. We are currently using email alerts (AND( ISCHANGED(StageName), Probability = 1, NOT(Owner.Id = "005d0000001TUC8")) but would like to move the interaction to chatter: 

 

Below is my attempt but

 

1. When I try this I get the error - Compile Error: unexpected token: insert at line 26 column 8 

2.As it is in the workflow - I would like to have one person's opportunitiy's (NOT(Owner.Id = 005d0000001TUC8) not trigger this workflow for privacy reasons

 

Could anyone help me clean this up? Thank you so much!

 

trigger ChatterWonOpportunity on Opportunity (after insert, after update) {

String status;
String OppAccName;
//Decimal OppAmount;
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(Trigger.isInsert) {
                               if(o.IsWon == true && Trigger.oldMap.get(o.id).IsWon == false) {
                    for (Opportunity oppty : [SELECT Account.Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                    }
                   o.owner +' just won' + OppAccName + 'for' o.expectedrevenue + ‘!';
                    }
                    else {
                        return;
                    }
                }
            
            post.ParentId = //0F9K000000005LR
            post.Title = o.Name;
            post.Body = status;
            }
        }
        insert post;
    }
}

 

  • August 06, 2013
  • Like
  • 0