• hyden matt007
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I am writing a trigger where I am bringing in a Date/Field field from case. It has a letter in it 2023-02-10T16:15:35.000+0000 and when I try to subtract it with "DateTime.now()" I get an error "Date/time expressions must use Integer or Double or Decimal ".

This is my code 
trigger CaseTrigger on Case (before update) {
     for(Case cases: Trigger.new){ 
         if(cases.stopped_time__c != null){
             cases.Total_amount_of_time_in_Hours__c= (DateTime.now()-cases.stopped_time__c );
         } 
    }
}
When checking this challenge, I get an error stating that the quickContact Lightning Component could not be found. Including screenshots of the steps I took thus far. Any advice would be appreciated!

1. The Lightning component must be named quickContact (this comes as part of the package, confirmed in picture below)
User-added image

2. Create a new action with Label Quick Contact and Name Quick_Contact on the Account object that invokes the quickContact component. (confirmed in picture below)
User-added image
3. Add the appropriate interfaces to the quickContact component. (Hint: there are two.) (used the implements force:lightningquickaction AND the force:hasrecordid on line 1, confirmed in picture below)
User-added image

4. Add the action to the Account Layout page layout. (added in picture below)
User-added image
The following formula will calculate the number of working days (inclusive) between 2 dates. A working day is defined as Monday to Friday. Even if the start or end dates are a weekend, these are accommodated.

IF(AND((5 - (CASE(MOD( Start_Date__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( End_Date__c  -   Start_Date__c ) + 1) < 7)),
((CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( End_Date__c  -  Start_Date__c ) - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))


The Start Date and End Date fields are custom in the above example and can be replaced as required. If use of a DateTime field is required then the DATEVALUE function will be required.

I also recommend a simple field validation rule is added to check that the End Date is after the Start Date.
  • January 05, 2009
  • Like
  • 9