How Insert new case comment using Apex Trigger in salesforce?
Hi,
In this post i am trying to give a trigger example of creating case comments while creating case.
Task: I need to insert the CaseComment to all the Relevant Cases whenever New casecommnet is created or updated Using Trigger,
Trigger:
trigger updateCaseComment on CaseComment(after insert, after update) {
Map<Id,CaseComment> caseMap = new Map<Id,CaseComment>();
for (CaseComment t: Trigger.new){
caseMap.put(t.ParentId,t);
}
Set<Id> idSet = caseMap.keySet();
List<Case> allCases = [select Id,ParentId from Case where ParentId in :idSet];
List<CaseComment> childCommand = new List<CaseComment>();
for(integer i=0;i<allCases.size();i++){
CaseComment newCommmand = new CaseComment();
newCommmand.CommentBody = caseMap.get(allCases[i].ParentId).CommentBody;
newCommmand.IsPublished = TRUE;
newCommmand.ParentId = allCases[i].id;
childCommand.add(newCommmand);
}
if(!childCommand.isEmpty()){
insert childCommand;
}
}
That's it !!
18 comments:
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
Salesforce training |Salesforce training institute in Chennai
Thanks for sharing these niche piece of coding to our knowledge. Here, I had a solution for my inconclusive problems & it’s really helps me a lot keep updates…
Regards,
Salesforce training chennai |Salesforce training institutes in Chennai
Task: I need to insert the CaseComment to all the Relevant Cases whenever New casecommnet is created or updated Using Trigger. Thanks for sharing!!!
Log cabins
you can have a trigger run before an object's records are inserted into the database, after records have been deleted, or even after a record is restored from the Recycle Bin. Please visit for more info on salesforce
Thanks for coding...of How Insert new case comment using Apex Trigger in salesforce.....
create salesforce form
Wonderful post!!Thank you for sharing this info with us.
Keep updating I would like to know more updates on this topic
Very useful content, I would like to suggest this blog to my friends.
Salesforce Training in Chennai
Salesforce Developer 502 Training in Chennai
Your website is worth to visit all of your posted content which was very interesting to read. Thanks a lot to share information like this.
Salesforce Training in Chennai
Salesforce Training
An informative blog and it is very useful
salesforce developer training in chennai
Salesforce Course
Good job. Nice blog about this technology.
Very useful for the freshers. Good keep it up.
salesforce developer training in chennai
best salesforce training in chennai
best training institute for salesforce in chennai
salesforce institutes in bangalore
best salesforce training in bangalore
best salesforce training institute in bangalore
Excellent blog I visit this blog it's really awesome. The important thing is that in this blog content written clearly and understandable. The content of information is very informative.
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
your explanation way is too good, very easy to understand for all readers. Thank you for providing the best details and I want more unique posts.
Primavera Training in Chennai
Primavera Course in Chennai
Tableau Training in Chennai
Spark Training in Chennai
Power BI Training in Chennai
Excel Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai
Social Media Marketing Courses in Chennai
Thanks for sharing this valuable information and we collected some information from this blog.
Salesforce Training in Gurgaon
This is an interesting blog that you have posted, you shares a lot of useful things about Technology.
Manual Testing Training in Chennai
manual testing course fees in chennai
Manual Testing Training in OMR
Mobile Testing Training in Chennai
Mobile Application Testing Training
Mobile App Testing Training
Drupal Training in Chennai
Photoshop Classes in Chennai
Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.
Tally Course in Chennai
Tally Classes in Chennai
ui design course in chennai
CCNA Training in Chennai
ReactJS Training in Chennai
microsoft dynamics crm training in chennai
Tally Training in Chennai
This was an well written blog. The admin has really shared a very useful content in a clear way. Thanks for sharing.
IELTS Classes in T Nagar
IELTS Coaching In Velachery
IELTS Coaching in Tambaram
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
English Speaking Classes in Mumbai
IELTS Coaching in Chennai
IELTS Classes in Mumbai
Thanks for sharing this information!
I totally agree with you. Your information is very interesting and important. I really like this information.
Our easy web plans company is famous in Advanced " http://vgrowsoft.com/"> Salesforce Live Online Training, Salesforce Online Training .
If you want to see our training venue then click on links:
http://vgrowsoft.com/
Call Now: 9121754693
Drop Mail: vgrowsoft@gmail.com
Thanks a lot for sharing a valuable blog on Oracle PPM Cloud Training. I was browsing through the internet looking for Oracle PPM Cloud and Oracle fusion applications and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can find more information about Oracle PPM Cloud by attending Oracle PPM Cloud Training. You can learn about interview questions by visiting fusion Interview Questions
Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle PPM Cloud . Actually I was looking for the same information on internet for Oracle Project Portfolio Management (PPM) Cloud Tutorial and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle PPM Cloud . By attending Oracle PPM Cloud Training .
Post a Comment