-
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
Why all Salesforce Users Should Integrate Their Systems
A common scenario with organizations using Salesforce is having a scenario where employees from different departments, are not able to access the same accurate, real-time…
Delete Default RecordType for Chatter User Profiles | Salesforce Developer Guide
There was a situation where I had to delete a Record Type from an Object and Page Layout for that Record Type. The record type…
Popular Salesforce Videos
Introduction to Salesforce
The topics covered in this video: Cloud Computing Salesforce CRM Basics Navigating UI Salesforce Environment Trailhead Basics Related Trails for this session: Trailhead Basics Salesforce…
Salesforce Financial Services Cloud Spring '23 Highlights
Shake off those winter blues with the new features coming in Salesforce's Spring '23 Release for Financial Services Cloud. Whether it's ARC enhancements, interaction summary…
How to Log an Admin Assist Support Case in Help and Training in Salesforce Help
Do you need to log a case with Admin Assist Salesforce Support but aren't sure how to go about it? Do you need help filling…