-
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
2023 CRM Landscape: A Deep Dive into Salesforce vs Microsoft Dynamics
Business rivalry with healthy competition is quite common among all industries. It eliminates monopoly and gives more options to choose for users. When it comes…
Custom Objects and Standard Objects in Salesforce - The Understanding
As evidenced by its predominance across nearly every industry able to leverage CRM or automation tools, the greatest value proposition Salesforce has to offer is…
Everything You Need to Know about Salesforce Partner Portal
Implementing a robust partner portal becomes paramount as businesses strive to foster stronger partner relationships and expand their reach. Salesforce Partner Portal offers a powerful solution…
Popular Salesforce Videos
Create Customers for Life with the Loyal Program in Salesforce
Ever thought about how you can retain your customers in this cutthroat competition in this growing market? A customer loyalty program is one of the…
Salesforce Lightning: Custom Theming and Branding
As part of myLightning, Custom Theming and Branding for Lightning Experience lets you customize key styling elements, such as the global header color, brand image,…
What are Custom Page Layout in Salesforce?
Custom Page Layout is creating its own layout and modifying the same layout which we have created. Watch this video to learn all about Custom…