-
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
Top Salesforce Trends To Watch Out In 2024
The cloud is a powerful tool that can help businesses grow exponentially. Top Salesforce CRM Trends in 2024 Let’s dig deeper into the current trends…
Salesforce Web3: All You Need to Know
What are NFTs? Before we get into the mechanics of what a Salesforce NFT Cloud could mean, let’s first define what an NFT is! NFT…
What is the Salesforce Experience Cloud? | The Ultimate Guide
Salesforce Experience Cloud, formerly known as Community Cloud, is a platform designed to help companies build and customize online communities for their customers, partners, and…
Popular Salesforce Videos
eShopSync for QuickBooks - A Salesforce QuickBooks Connector
One of the best Quickbooks Integration Solution With Salesforce. It efficiently sends QuickBooks data (Categories, Users, Products, and Orders) to Salesforce. For more information, please…
Security Best Practices for Building Lightning Components
Lightning Component is a framework to build Salesforce applications faster. If you are using Salesforce1, you already experiencing the Lightning. It is based on an…
Guided Setup with Salesforce Field Service Administration - Webinar Recording
Salesforce Field Service is a complete, end-to-end solution for customer service in the field. Salesforce Field Service brings together customers, employees, and products on a…