• Chris Grover
  • NEWBIE
  • 10 Points
  • Member since 2018
  • Unisys

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I cannot resolve this error'Date expressions must use Integer or Long (8:45)'
trigger WarrantySummary on Case (before insert) {
   
for (Case myCase : Trigger.new){
// Set up variables to use in the summary field
 Date purchaseDate           = myCase.Product_Purchase_Date__c;
 Datetime createdDate        = myCase.CreatedDate;
 Integer warrantyDays        = myCase.Product_Total_Warranty_Days__c.intValue();
 Decimal warrantyPercentage  = purchaseDate.daysBetween(Date.today()) / warrantyDays;
 Boolean hasExtendedWarranty = myCase.Product_Has_Extended_Warranty__c;

//Populate summary field
 myCase.Warranty_Summary__c = 'Product Purchased on ' + purchaseDate + ' '
  + 'and case created on '  + createdDate + '.\n'
  + 'Warranty is for '      + warrantyDays + ' '
  + 'and is '               + warrantyPercentage +'% through its warranty period.\n'
  + 'Extended warranty: '   + hasExtendedWarranty + '\n'
  + 'Have a nice day!';
    }


}
I am having issues with this challenge
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: HKXULUEI
Getting following error for the code :

                                <img src="{!$ContentAsset.03S1w0000004Z6l}" alt="TLogo" class="tlogo"/> 

Error:
Failed to save xxxxxx.cmp: unexpected token: a floating point number at column 14 of expression: $ContentAsset.03S1w0000004Z6l: Source
I cannot resolve this error'Date expressions must use Integer or Long (8:45)'
trigger WarrantySummary on Case (before insert) {
   
for (Case myCase : Trigger.new){
// Set up variables to use in the summary field
 Date purchaseDate           = myCase.Product_Purchase_Date__c;
 Datetime createdDate        = myCase.CreatedDate;
 Integer warrantyDays        = myCase.Product_Total_Warranty_Days__c.intValue();
 Decimal warrantyPercentage  = purchaseDate.daysBetween(Date.today()) / warrantyDays;
 Boolean hasExtendedWarranty = myCase.Product_Has_Extended_Warranty__c;

//Populate summary field
 myCase.Warranty_Summary__c = 'Product Purchased on ' + purchaseDate + ' '
  + 'and case created on '  + createdDate + '.\n'
  + 'Warranty is for '      + warrantyDays + ' '
  + 'and is '               + warrantyPercentage +'% through its warranty period.\n'
  + 'Extended warranty: '   + hasExtendedWarranty + '\n'
  + 'Have a nice day!';
    }


}