• Shobit Gupta
  • NEWBIE
  • 74 Points
  • Member since 2014

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 13
    Replies
Product_Purchase_Date__c, Product_Total_Warranty_Days__c, Product_Has_Extended_Warranty__c are the custom fields on Case object. I am trying to summarise them within a text and display on the 'Warranty_Summary__c '  field

Any help would be appreciated. Thank you!

trigger WarrantySummary on Case (before insert) {
    
    
    
    for(Case nCase : Trigger.new){
        //Setting up variable to use in the summary field
        String purchaseDate             = nCase.Product_Purchase_Date__c.format();
        String createdDate                 = DateTime.now().format();
        Integer totalNoOfWarrantyDays    = nCase.Product_Total_Warranty_Days__c.intValue();
        Decimal warrantyPercentage      = (100 * (nCase.Product_Purchase_Date__c.daysBetween(Date.today()) 
                                          / nCase.Product_Total_Warranty_Days__c)).setScale(2);
        Boolean hasExtendedWarranty     = nCase.Product_Has_Extended_Warranty__c;
        
        //Populating the summary field
        nCase.Warranty_Summary__c       = 'Product purchased on ' + purchaseDate + ' ' + 'and case created on ' + createdDate + '.\n' 
                                        + 'Warranty is for ' + totalNoOfWarrantyDays + ' ' + 'days and is ' + warrantyPercentage + 
                                        '% through its warrant period.\n' + 'Extended warranty: ' + hasExtendedWarranty + '/n' + 
                                        + 'Have a nice day!';
        
        
                                        
       }
}
Hello,
Few fields are visible in Rollup summary but few not.
One of the field is Formula (Currency), which is available but other has same type but it is not visible. 

User-added image

what can be the reason ?
  • November 22, 2019
  • Like
  • 0
Product_Purchase_Date__c, Product_Total_Warranty_Days__c, Product_Has_Extended_Warranty__c are the custom fields on Case object. I am trying to summarise them within a text and display on the 'Warranty_Summary__c '  field

Any help would be appreciated. Thank you!

trigger WarrantySummary on Case (before insert) {
    
    
    
    for(Case nCase : Trigger.new){
        //Setting up variable to use in the summary field
        String purchaseDate             = nCase.Product_Purchase_Date__c.format();
        String createdDate                 = DateTime.now().format();
        Integer totalNoOfWarrantyDays    = nCase.Product_Total_Warranty_Days__c.intValue();
        Decimal warrantyPercentage      = (100 * (nCase.Product_Purchase_Date__c.daysBetween(Date.today()) 
                                          / nCase.Product_Total_Warranty_Days__c)).setScale(2);
        Boolean hasExtendedWarranty     = nCase.Product_Has_Extended_Warranty__c;
        
        //Populating the summary field
        nCase.Warranty_Summary__c       = 'Product purchased on ' + purchaseDate + ' ' + 'and case created on ' + createdDate + '.\n' 
                                        + 'Warranty is for ' + totalNoOfWarrantyDays + ' ' + 'days and is ' + warrantyPercentage + 
                                        '% through its warrant period.\n' + 'Extended warranty: ' + hasExtendedWarranty + '/n' + 
                                        + 'Have a nice day!';
        
        
                                        
       }
}
While running the batch Apex I got this error "Apex heap size too large: 12239748"
Hi

I want to get the current month from picklist field and use that current month in soql query in a batch class. I have written the following code and its not working. 
Any help is appreciated.

String month = Product.Month__c.month();
Set<String> ple = new Set<String> {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
String query = 'Select Id, Name, Month__c from Product where CALENDAR_MONTH(Month__c) = :month';

 
Hello,
Few fields are visible in Rollup summary but few not.
One of the field is Formula (Currency), which is available but other has same type but it is not visible. 

User-added image

what can be the reason ?
  • November 22, 2019
  • Like
  • 0
Hi,
  I Have This Requirement,
"Projects (drop down sorted by date and client)."
Please Help me.

Thanks, Sesha.
 
I am having difficulty with the above step in that I can't find 'Related Accounts' anywhere; can someone please help? Thanks.

Trailhead module:
Learn CRM Essentials for Salesforce Classic Accounts & Contacts
Understand Account and Contact Relationships

Hi There,


I have a Salesforce Process that automatically changes a Contact's Owner to match the Account Owner upon Account Owner Change. 

This process seems to be getting tripped up by a Marketo Trigger from the Marketo Sales Insights Managed Package, but I cannot see the code behind it to troubleshoot. Here is the error message I get: 

"UPDATE --- UPDATE FAILED --- ERRORS : (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) mkto_si.RemoveInterestingMomentLinebreaksContact: System.LimitException: Apex CPU time limit exceeded" 

I wrote to Marketo and they said this:

"The Apex CPU trigger is actually within Salesforce. As we do not have any access to drill down into Salesforce, we cannot fix it. Marketo isn't causing the Apex trigger, Marketo is trying to update a field within Salesforce and the Salesforce Apex CPU time out is happening before Marketo's update can process. This is why you are getting the update failed error. "

My gut says it's because the code within the trigger, but I can't see it because it's a managed package.

Anyone have any work around for this? I am just updating ~100 account records so I'm not sure why this would be timing out. 

Hi All,

I have the following code that checks duplicate for email and phone for contact records. For instance, R1 contact record can have phone, email as "123","a@abc.com" and R2 contact record can have "123","b@abc.com". Error thrown only when BOTH EMAIL, PHONE matches existing records.
This works for single record insert/update, but when bulk insert through data import wizard if I insert 10 records with same email,phone values, 9 records are inserted with duplicate values, with error on the 10th record. 

Need help.
Thanks.

-----------------------------

trigger ContactTrigger_AT on Contact (before insert, before update)
{
    Set<String> setEmail = new set<String>();
    Set<String> setPhone = new set<String>();
    Set<String> setExistingEmail = new set<String>();
    Set<String> setExistingPhone = new set<String>();
    
    for(Contact con : Trigger.new)
    {
        setEmail.add(con.email);
        setPhone.add(con.Phone);
    }
    for(Contact con : [SELECT Phone,Email FROM contact WHERE email in : setEmail AND phone in : setPhone])
    {
        setExistingEmail.add(con.email);
        setExistingPhone.add(con.Phone);
    }
       if(Trigger.isInsert||Trigger.isUpdate)
    for(Contact a:trigger.new)
     {
        if(setExistingEmail.contains(a.email) && setExistingPhone.contains(a.Phone))
        {
            a.adderror('This Phone and email already exists');
        }
    }

}
Hello.

I have a test class for a trigger that has a 100% code coverage when I run it in Sandbox. However, when I try to validate it in live, I get the following error:
System.DmlException: Update failed. First exception on row 0 with id a07A000000d5UuvIAE; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CCPSSupEvent: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 1; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Trigger.CCPSSupEvent: line 118, column 1: [] 
Stack Trace: Class.Test_CCPSSupEvent.myTestMethod1: line 30, column 1


Here is my trigger:
trigger CCPSSupEvent on CCP__c (after insert, after update) {

  if(checkRecursive.runOnce()) {   
        String calendarSubject;
        string ssName = '';
        
        if (System.Trigger.isInsert) {
            List<Event> events = new List<Event>();
            
            for (CCP__c c: Trigger.New) {
                
                if(c.Is_Rep_Required_to_Attend__c == true) {
                    calendarSubject = '@@@ CCP1 - ' + c.Name;
                } else  {
                    calendarSubject = 'CCP1 - ' + c.Name;
                } 
                
                if (c.Must_Deliver_On_Datetime__c != null) {
                
                    // add to the Sales Support calendar
                    if (c.Additional_Support__c != null) {  
                        events.add( new Event(
                            OwnerID = c.Additional_Support__c,
                            WhatID = c.ID,
                            ActivityDate = c.Must_Deliver_on_Date__c,
                            ActivityDateTime = c.Must_Deliver_on_DateTime__c,
                            Subject = calendarSubject,
                            Description = 'CCP Event - ' + c.Name,
                            DurationInMinutes = 120,
                            ShowAs = 'Free',
                            Type = 'CCP',
                            CCP_Master_Event__c = True,
                            Location = c.Customer_Name__c)
                        );
                    }
                
                    // add to the Sales Support public calendar
                    if (c.Additional_Support__c != null) {                
                        User u = [Select Full_Name__c from User where id = :c.Additional_Support__c];
                        ssName = u.Full_Name__c; 
                        
                        events.add( new Event(
                            OwnerID = '0234B000000V3cX',
                            WhatID = c.ID,
                            ActivityDate = c.Must_Deliver_on_Date__c,
                            ActivityDateTime = c.Must_Deliver_on_DateTime__c,
                            Subject = ssName + '-' + calendarSubject,
                            Description = 'CCP Event - ' + c.Name,
                            DurationInMinutes = 120,
                            ShowAs = 'Free',
                            Type = 'CCP',
                            CCP_Master_Event__c = True,
                            Location = c.Customer_Name__c)
                        );
                    }   
                }         
            }
            insert events;
        } 
        
        else if (System.Trigger.isUpdate) {
        
            Set<Id> OldWhatIds = new Set<Id>(); 
            Set<ID> OldOwnerIds = new Set<Id>();                
            List<Event> events = new List<Event>();
            
            for (CCP__c c: Trigger.New) {
                
                if(c.Is_Rep_Required_to_Attend__c == true) {
                    calendarSubject = '@@@ CCP2 - ' + c.Name;
                } else  {
                    calendarSubject = 'CCP2 - ' + c.Name;
                } 
                
                if (c.Must_Deliver_On_Datetime__c != null
                    && c.Additional_Support__c!= System.Trigger.oldMap.get(c.Id).Additional_Support__c) 
                {        
                    if (c.Additional_Support__c!= null) 
                    {    
                        events.add( new Event(
                            OwnerID = c.Additional_Support__c,
                            WhatID = c.ID,
                            ActivityDate = c.Must_Deliver_on_Date__c,
                            ActivityDateTime = c.Must_Deliver_on_DateTime__c,
                            Subject = calendarSubject + '--1',
                            Description = 'CCP Event - ' + c.Name,
                            DurationInMinutes = 120,
                            ShowAs = 'Free',
                            Type = 'CCP',
                            CCP_Master_Event__c = True,
                            Location = c.Customer_Name__c)
                        );
                        
                        User u = [Select Full_Name__c from User where id = :c.Additional_Support__c];
                        ssName = u.Full_Name__c;
                
                        events.add( new Event(
                            OwnerID = '0234B000000V3cX',
                            WhatID = c.ID,
                            ActivityDate = c.Must_Deliver_on_Date__c,
                            ActivityDateTime = c.Must_Deliver_on_DateTime__c,
                            Subject = ssName + '-' + calendarSubject + '--1',
                            Description = 'CCP Event - ' + c.Name,
                            DurationInMinutes = 120,
                            ShowAs = 'Free',
                            Type = 'CCP',
                            CCP_Master_Event__c = True,
                            Location = c.Customer_Name__c)
                        );
                    }                    
                }
                OldWhatIds.add(c.ID);
                OldOwnerIds.add(System.Trigger.oldMap.get(c.Id).Additional_Support__c);
            } 
            List<Event> OldEvents = [select Id, WhatId, OwnerId from Event where WhatID IN : OldWhatIds AND OwnerID IN : OldOwnerIds];
            delete OldEvents; 
                  
            insert events;
        }                                
    }
}

Here is my test class:
@isTest (SeeAllData = true)
public class Test_CCPSSupEvent {
    static testmethod void myTestMethod1() {
        User u1    = [select Id from User where alias='lyogi' LIMIT 1];
        
        String OrderNumberX  = '9991111';
        String OrderNameX    = OrderNumberX + '-Test CCP Record x';
        String OrderNumberY = '9992222';
        String OrderNameY   = OrderNumberY + '-Test CCP Record y';
        User SSupID1              = [select Id from User where Alias = 'NTarb' LIMIT 1]; 
        User SSupID2              = [select Id from User where Alias = 'KMurp' LIMIT 1];
        String SSup1              = SSupID1.Id;
        String SSup2              = SSupID2.Id;
                       
        RecordType RecRetailID    = [select Id from RecordType where Name = 'Retail Assistance'];
        String RecRetail          = RecRetailID.Id;
        
        System.RunAs(u1) {
        
            CCP__c c1 = new CCP__c(Name = OrderNameX, Order_Number__c = OrderNumberX, RecordTypeID = RecRetail, Must_Deliver_On_Datetime__c = System.today().addDays(2), Is_Rep_Required_to_Attend__c = false);
            insert c1;
            
            checkRecursive.resetAll();
            List<CCP__c> c2 = new List<CCP__c>();
            for(CCP__c c2u:[SELECT Id, Must_Deliver_On_Datetime__c, Additional_Support__c, Is_Rep_Required_to_Attend__c FROM CCP__c WHERE Order_Number__c = :OrderNumberX]) {
                c2u.Additional_Support__c = SSup1;
                c2u.Is_Rep_Required_to_Attend__c = true;
                c2.add(c2u);
            }
            update c2;
            
            checkRecursive.resetAll();
            List<CCP__c> c3 = new List<CCP__c>();
            for(CCP__c c3u:[SELECT Additional_Support__c, Is_Rep_Required_to_Attend__c FROM CCP__c WHERE Order_Number__c = :OrderNumberX]) {
                c3u.Additional_Support__c = SSup2;
                c3u.Is_Rep_Required_to_Attend__c = false;
                c3.add(c3u);
            }
            update c3;                
            
            checkRecursive.resetAll();
            List<CCP__c> c4 = new List<CCP__c>();        
            for(CCP__c c4u:[SELECT Id FROM CCP__c WHERE Order_Number__c = :OrderNumberX]) {
                c4.add(c4u);
            }
            delete c4;
    
            checkRecursive.resetAll();
            CCP__c c6 = new CCP__c();
            c6.Name = OrderNameY;
            c6.Order_Number__c = OrderNumberY;
            c6.RecordTypeID = RecRetail;
            c6.Is_Rep_Required_to_Attend__c = true;
            c6.Must_Deliver_On_Datetime__c = System.today().addDays(3);
            c6.Additional_Support__c = SSup2;
            insert c6; 
            
            checkRecursive.resetAll();
            List<CCP__c> c7 = new List<CCP__c>();
            for(CCP__c c7u:[SELECT Must_Deliver_On_Datetime__c FROM CCP__c WHERE Order_Number__c = :OrderNumberY]) {
                c7u.Additional_Support__c = null;
                c7u.Must_Deliver_On_Datetime__c = null;
                c7.add(c7u);
            }
            update c7;  
            
            checkRecursive.resetAll();
            List<CCP__c> c9 = new List<CCP__c>();        
            for(CCP__c c9u:[SELECT Id FROM CCP__c WHERE Order_Number__c = :OrderNumberY]) {
                c9.add(c9u);
            }
            delete c9;
        }
    }
}
I would appreciate any help. Thanks.
Irene
Could anybody let me know the Differnce between salesforce record URLand Service console record URL. And how can we get the service console record URL dynamically to use in formula filed and that URL should work in production as well.

Any Suggestion welcome.
Thanks In Advance.
Hi,

I am getting the error in the production,please help me how to figure out the issue in the sandbox.

Please Check the below screen shot and Kindly help me

Thanks &Regards,
Pavan VempatiError in Production trying to replicate in sandbox
Trying to complete this challenge.  Recieve the following error message.  Need help resolving:

"Challenge not yet complete... here's what's wrong: 
The page does not bind to the record ID value (in order to link to the record detail page)"

Here's my code for 'AccountList.vfp':

<apex:page standardController="Account" recordSetVar="accounts">
    <table border="1" >
  
        <apex:repeat var="a" value="{!Account}">
            <li>
                <apex:outputLink value="/<record id>">
                    Record
                </apex:outputLink>
            </li>
        </apex:repeat>
            
    </table>
</apex:page>