-
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 Much Does a Salesforce Implementation Cost?
Introduction Before moving ahead, let's first understand what CRM is and why it is important for businesses, as Salesforce is a CRM software. CRM is…
What is the Database.Stateful Interface in Batch Apex?
We know Salesforce has a powerful way to do bulk processing with Batch Apex. However, I rarely come across scenarios where Database.Stateful is needed. Batch…
Who Ya Gonna Call – ‘No Longer Your IT Team’ - (How To Enhance Your Value As A Salesforce Admin!)
Telephony has forever and a day been a dark art , thrust into the hands of the IT Department who typically do not have the…
Popular Salesforce Videos
Simplified Non-Functional Testing for Salesforce Developers
Testing is indispensable to measure, optimize performance, and improve user experience. Watch this video to see how you can measure performance across physical mobile devices…
Salesforce Admin 201 Training for Beginners: Different Types of Relationship in Salesforce
The Salesforce Certified Administrator program is designed for individuals who have experience as a Salesforce administrator. The program encompasses the breadth of applications, the features…
Rollup Trigger via Salesforce Record Triggered Flow - Trigger without code
Hello Folks, I created a Rollup trigger via Salesforce Record Triggered Flow (without code cool isn't). I use Record trigger Flow for that scenario. There…