-
How can I test this class in Salesforce?
I am creating a new Content Link on Service Appointment inserting from the parent work order and I am struggling on how I would write a test against this.
trigger LinkWorkOrderContentToServiceAppointment on ServiceAppointment (after insert) {
List<ContentDocumentLink> CDLtoUpdate = new List<ContentDocumentLink>();
Set<ID> TicketIDs = new Set<ID>();for (ServiceAppointment SA : Trigger.new) {
TicketIDs.add(SA.Master_Ticket__c);
}List<ContentDocumentLink> ContentDocumentLinks = new List<ContentDocumentLink>([select id,ContentDocumentId,LinkedEntityId from ContentDocumentLink where LinkedEntityId in:TicketIDs]);
for (ContentDocumentLink CDL : ContentDocumentLinks){
for (ServiceAppointment SA : Trigger.new){
if(CDL.LinkedEntityId == SA.Master_Ticket__c){
if(CDLtoUpdate.size()>199){
insert CDLtoUpdate;
CDLtoUpdate.clear();
}
ContentDocumentLink NCDL = new ContentDocumentLink(ContentDocumentId = CDL.ContentDocumentId, LinkedEntityId = SA.Id, ShareType ='V', Visibility = 'AllUsers');
CDLtoUpdate.add(NCDL);
}
}
}
if(CDLtoUpdate.size() > 0){
insert CDLtoUpdate;
CDLtoUpdate.clear();
}}
Log In to reply.
Popular Salesforce Blogs
How Can CRM Solutions Help to Build Your Brand | Salesforce
This is an undeniable fact that in today’s technologically progressive era, the business market is extremely competing. To survive successfully in such a vying business…
Apex Intention Actions: The Next Frontier for Apex Completions
Idea from IDEa Recently, I needed to code a little tool in Java. The last time I coded something in Java was in high school,…
Certified Salesforce Consulting Partner – A Game Changer for Businesses
In today’s digital world, businesses rely on Customer Relationship Management (CRM) platforms like Salesforce to streamline operations, enhance customer engagement, and drive sales growth. However,…
Popular Salesforce Videos
Salesforce Financial Services Cloud Implementation Guide
You’ve decided to use Salesforce Financial Services Cloud but where do you begin? How can you utilize Salesforce to track all your customer interactions and…
How To Use Javascript Editor In Formstack Part 2 - Learn Salesforce Series By Algoworks
Learn how to integrate Javascript editor in Formstack in this Salesforce tutorial brought to you by Algoworks. Did you miss the complete tutorial? To watch…
How to Become Salesforce Certified Architect: Achieve More Under Pressure
Achieve more under pressure: CTA Edition How to become Salesforce Certified Architect 0:00 Introduction 5:21 What is CTA exam about 10:37 What is CTA Exam…