-
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
Leverage the Power of Salesforce Marketing Cloud Account Engagement for Inbound Marketing
Inbound marketing is an effective strategy for producing excellent content that meets the demands of your target markets and fosters enduring relationships with customers. Because…
Outsourcing Strategic CRM Support: A Case for Salesforce Service Cloud Consultant
In today's dynamic business landscape, customer relationship management (CRM) plays a pivotal role in the success of any organization. As businesses strive to build lasting…
Salesforce User Stories: Salesforce Adoption Experience of FinTech Leaders Globally
The fintech market is substantially evolving and has an expected value of $698.48 billion by 2030, a considerable contrast to its $110.57 billion valuation in…
Popular Salesforce Videos
See how fast and easy you can make intuitive Salesforce solutions to your users with Cauzali.
Instead of coding or very complex flows use Cauzali. Place your Cauzali model everywhere in Salesforce including in the middle of a Flow. Price between…
Dreamforce 2021 FAQs
As the fall continues to approach, questions around Dreamforce 2021 continue to increase and that's why we've gone ahead and answered all the FAQs around…
Strategy Design Pattern in Salesforce | Video Tutorial
Design Patterns are very important for us to understand to develop an efficient apex code. Watch this video to learn all about it and do…