-
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
Salesforce Customer Portal: Features, Industry Use Case, and Benefits
The ideal features in a customer portal may vary depending on the industry, business needs, and the types of customers that the portal is meant…
How to Perform Multiple Field Operations in Salesforce?
Do field operations in Salesforce org consume the bulk of your time? Are you always engaged in creating, cloning, updating, deleting & exporting those thousands…
Popular Salesforce Videos
When to Code, Configuration, Code + Configuration in Salesforce
When to Code, Configuration, Code + Configuration in Salesforce by Nikunj Doshi, Salesforce Certified Technical Architect In this session: - Key Criteria in deciding the…
Custom Login Page Using Mulesoft | Salesforce Tutorial
In this video, you will learn how to create a custom login page using Mulesoft. Watch and learn. If you have any doubts do let…
Salesforce Winter Release '22 Highlights
Watch this webinar video to learn about new and improved features and how you can take full advantage of the latest enhancements. Let us know…