You need to sign in to do that
Don't have an account?
Anshuman Parhi
[Response Date cannot include Saturday/ Sunday in calculation as they are not business days]
Any solution for this..
Apex trigger devlopment
- Create custom object ‘Complaints’ with appropriate fields. It will have ‘Response Date’ field (Date/time). It will also have ‘Priority’ field (Picklist). Write a code which will auto-update Response Date field based on Priority using following mapping:
Priority | Response Date |
Critical | Creation Date + 6 Business Hours |
High | Creation Date + 2 Business Days |
Medium | Creation Date + 5 Business Days |
Low | Creation Date + 10 Business Days |
[Response Date cannot include Saturday/ Sunday in calculation as they are not business days]
Any solution for this..
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
>> for creating the custom object you can go to setup and follow the below steps to create a custom object with custom fields.
https://trailhead.salesforce.com/content/learn/modules/create-a-custom-object-quick-look/create-a-custom-object
For trigger, you can use the below link and modify the snippet present in it to fit your use case:
>> https://salesforce.stackexchange.com/questions/79090/using-businesshours-add-for-calculating-a-due-date-in-a-datetime-field
I am adding the snippet here for quick reference:
Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.
Thanks.
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
Can anyone give me the test cases for this code.I have tried it but it is showing 40% code coverage.
Here is my test class:
@isTest
public class ComplaintsTest {
@isTest
public static void testComplaintsClass(){
List<Complaint__c> cc= [SELECT id,Name, Response_Date__c,Priority__c FROM Complaint__c WHERE Name='My first Case'];
Datetime myDateTime = ComplaintsHandler.updateResponseDate(cc);
Datetime myDateTimeExpected = Datetime.newInstance(2021, 7, 27);
System.assertEquals(myDateTimeExpected,myDateTime);
}
@isTest
public static void testComplaintsClassSecond(){
List<Complaint__c> cc= [SELECT id,Name, Response_Date__c,Priority__c FROM Complaint__c WHERE Name='Test 1'];
String s='';
for(Complaint__c clist:cc){
s=clist.Priority__c;
}
if(s.equals('Low')){
Datetime myDateTime=ComplaintsHandler.updateResponseDate(cc);
Datetime myDateTimeExpected = Datetime.newInstance(2021, 8, 10);
System.assertEquals(myDateTimeExpected,myDateTime);
}
}
}