You need to sign in to do that
Don't have an account?
Ryan Reese
how do i deploy code
So I entered this code in my sandbox with a test opportunity and chatter group but how do I deploy to production
trigger OppWonChatter on Opportunity (after insert, after update) {
String status;
String OppAccName;
String OppOwnerName;
FeedItem post = new FeedItem();
for(Opportunity o : Trigger.new) {
if(o.OwnerId == '00560000001MxXV') { //It will not post record for for this user to group. changed last letter to cap v so i can test
return;
}
else {
if(Trigger.isInsert ) {
if( o.IsWon == true ) { //This will be executed on new record insertion
for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
OppAccName = oppty.Account.Name;
OppOwnerName = oppty.Owner.Name;
}
status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.expectedrevenue + '!';
post.ParentId = '0F9m00000008ZTM';
post.Title = o.Name;
post.Body = status;
insert post;
}
}
else {
if ( Trigger.isUpdate ) {
if( o.IsWon == true ) { //This will be executed on update to existing record
for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
OppAccName = oppty.Account.Name;
OppOwnerName = oppty.Owner.Name;
}
status = OppOwnerName + ' just won ' + OppAccName + '!';
post.ParentId = '0F9m00000008ZTM';
post.Title = o.Name;
post.Body = status;
insert post;
}
}
}
trigger OppWonChatter on Opportunity (after insert, after update) {
String status;
String OppAccName;
String OppOwnerName;
FeedItem post = new FeedItem();
for(Opportunity o : Trigger.new) {
if(o.OwnerId == '00560000001MxXV') { //It will not post record for for this user to group. changed last letter to cap v so i can test
return;
}
else {
if(Trigger.isInsert ) {
if( o.IsWon == true ) { //This will be executed on new record insertion
for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
OppAccName = oppty.Account.Name;
OppOwnerName = oppty.Owner.Name;
}
status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.expectedrevenue + '!';
post.ParentId = '0F9m00000008ZTM';
post.Title = o.Name;
post.Body = status;
insert post;
}
}
else {
if ( Trigger.isUpdate ) {
if( o.IsWon == true ) { //This will be executed on update to existing record
for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
OppAccName = oppty.Account.Name;
OppOwnerName = oppty.Owner.Name;
}
status = OppOwnerName + ' just won ' + OppAccName + '!';
post.ParentId = '0F9m00000008ZTM';
post.Title = o.Name;
post.Body = status;
insert post;
}
}
}
See the following link on change sets for more info: https://help.salesforce.com/HTViewHelpDoc?id=changesets.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=changesets.htm&language=en_US)
As James Loghry mentioned, Changeset would be the best approach for Newbie(beginner)
Follow some best practices for Coding
75% of code coverage is required to deploy Apex Class to Prod, Every trigger must have some test coverage
(https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_best_practices.htm)
Hope ths Helps
Thanks
BLearn
How would I build the test class and what would be the basic structure be?
Thanks