-
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
Understanding Roles, Profiles and Permission Sets in Salesforce
Access management is arguably one of the most important components of front-line Salesforce security — but there's a lot more to it than just password…
Salesforce Vaccine Cloud: Streamline Vaccine Management
Things are changing now - after one full year. COVID-19 cases have gone down, people are out again (with safety precautions though), and the new…
Unpacking the Financial Realities of Salesforce Partner Transitions
Picking a software development partner is a big deal, affecting both your time and budget. People often worry about the hefty price tag of changing…
Popular Salesforce Videos
How Can Salesforce Marketing Cloud Help You Grow Your Business Exponentially?
Salesforce Marketing Cloud can help you take your marketing to the next level by providing an all-in-one platform that helps you strategize across multiple channels.…
Salesforce Lightning Tutorial | Salesforce Developer Training for Beginners
This salesforce developer training for beginners video is a salesforce lightning tutorial where you will learn introduction to salesforce, salesforce components, salesforce lightning, lightning vs…
Fillable PDFs for Salesforce Field Service
The ability to generate fillable PDFs for Salesforce Field Service can be a powerful tool. We demonstrate how to use PDFLib, a JavaScript library that…