-
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 CRM Systems Enhance Employee Productivity and Drive Business Success?
CRM systems have become essential tools for modern businesses, significantly enhancing employee productivity and driving overall success. By centralizing customer data, automating routine tasks, and…
What are Managed & Unmanaged Packages in Salesforce in 2023?
Salesforce is one of the most widely used Customer Relationship Management (CRM) tools in the world. It provides a platform for organizations to build, customize,…
Salesforce Software Engineer: The future
What is a Salesforce Consultant? A Salesforce Consultant conventionally wears different covers. They might work in-house inside an association or be contracted as an external…
Popular Salesforce Videos
Top 5 FAQs' of Salesforce Commerce Cloud
Salesforce Commerce Cloud, formerly known as Demandware, is a user-friendly and streamlined e-Commerce platform designed with a simple goal to help a company expand its…
Manual & Apex Managed Sharing in Salesforce
In this video, we will talk about Manual Sharing and Apex Managed Sharing. Manual Sharing Manual Sharing is used to share the record Manually. For…
Best Chrome Extensions for Salesforce
These are the best FREE Chrome Extensions to use with Salesforce. Installing Chrome extensions is the easiest way to enhance your experience on the Salesforce…