You need to sign in to do that
Don't have an account?
d.tejdeep@nicomatic.in
Ideas Regarding Trigger
trigger feeditemnofication on FeedItem (after update,after insert) {
for (feeditem F : Trigger.new)
{
if(Trigger.isInsert)
{
feeditem EE = [Select body,parentid from feeditem where Id = :F.Id];
opportunity op=[select id,ownerid from opportunity where id=:EE.parentid] ;
User U= [select id,Email,Name from user where id =:op.ownerid ];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {U.email};
mail.setToAddresses(toAddresses);
mail.setSubject('Record Feed Notification to record owner' );
mail.setPlainTextBody('Hello,' + '\n\n' +'Please consider the following feed'+' '+'\n\n'+'Subject :'+F.body );
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
In this parentid will of any thing like accound id ,opportunity id,quote id,userid--- i need to send email to the record owner when feed is posted .how i can write the code as global way (or) we need to write it seperately (if account id,if oppid,if quoteid).it woud be great it would have some sample code.
for (feeditem F : Trigger.new)
{
if(Trigger.isInsert)
{
feeditem EE = [Select body,parentid from feeditem where Id = :F.Id];
opportunity op=[select id,ownerid from opportunity where id=:EE.parentid] ;
User U= [select id,Email,Name from user where id =:op.ownerid ];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {U.email};
mail.setToAddresses(toAddresses);
mail.setSubject('Record Feed Notification to record owner' );
mail.setPlainTextBody('Hello,' + '\n\n' +'Please consider the following feed'+' '+'\n\n'+'Subject :'+F.body );
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
In this parentid will of any thing like accound id ,opportunity id,quote id,userid--- i need to send email to the record owner when feed is posted .how i can write the code as global way (or) we need to write it seperately (if account id,if oppid,if quoteid).it woud be great it would have some sample code.
Check if you can use type of in query. You will have to get it enabled by contacting salesforce.
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_typeof.htm
With that information you can check the RecordID, and if it starts with the Prefix you can determine the type.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_namespace_Schema.htm
Here is a sample code for using this in some Apex:
http://corycowgill.blogspot.com/2011/01/building-dynamic-soql-select-all-query.html
You code will look similar to:
for(Schema.SObjectType objType : sobjects)
{
objDescribe = objType.getDescribe();
String sobjectPrefix = objDescribe.getKeyPrefix();
if(id != null && sobjectPrefix != null && id.startsWith(sobjectPrefix))