-
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
Salesforce Nonprofit Cloud Summer '24 Highlights
Salesforce is turning up the heat on quality-of-life features in the Summer '23 Nonprofit Cloud update! Let's take a look at a couple of new…
Why Do Salesforce Implementation Fail and How to Avoid Them?
Salesforce CRM is a transformative tool that has revolutionized how businesses approach sales, marketing, and customer service. However, while many organizations have reaped its benefits,…
Why Salesforce Data Cloud is No Longer Optional for Modern Salesforce Teams
Businesses generate customer data from multiple touchpoints, including CRM systems, websites, marketing platforms, ERP applications, support channels, and third-party tools. When this information remains scattered…
Popular Salesforce Videos
How to use Salesforce Data to drive producivity and greater data capture
How do you encourage and drive better quality data entry into Salesforce by Salespeople? How do you use that data to drive productivity and proactive…
Creating a Salesforce Lightning App in 12 Minutes
Salesforce is the easiest and quickest way to make quality enterprise apps using clicks instead of code.This video attempts to demonstrate just how quick and…
Integrating a Node.js Application with Salesforce
Watch this video where we will explore how to integrate a Node.js web application with Salesforce using Heroku Connect and JSForce. You can work with…