-
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
Explore the True Potential of Hyperforce in Salesforce
Introduction to Hyperforce With Hyperforce, Salesforce application development services can swiftly and securely grow with the help of public cloud partners, thanks to a new…
The New Marketing Cloud Growth Edition: All You Need to Know
The Marketing Hustle for Small Businesses Running a small business is an exciting journey, but keeping up with marketing demands can feel overwhelming. Limited resources…
Top Salesforce Winter '23 Flow Features
In our next blog, we spoke about the Top 10 Salesforce Winter ‘23 release features. However, we cannot miss the most important Salesforce Flow features.…
Popular Salesforce Videos
All Things Telesales Podcast
Sales Director at Natterbox, Ian Moyse shares with us 3 Powerful Pillars of Servant Leadership - Yearning, Earning, Learning. Ian drops wisdom bombs left and right…
Salesforce Admin Tutorial for Beginners 2022
Complete Salesforce Admin Tutorial 00:00:00 Salesforce - Introduction 00:01:27 Salesforce - Types of Services 00:02:21 Salesforce - Cloud Services 00:07:51 Salesforce - Developer Account 00:16:09…
Leads & Opportunities for Lightning Experience - Create and Convert Leads
Learning Objectives After completing this unit, you’ll be able to: Update a record’s stage or status using Path. Update records in the Kanban view. Use…