• sachinarorasf
  • SMARTIE
  • 1032 Points
  • Member since 2018
  • Cloud Analogy


  • Chatter
    Feed
  • 34
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 230
    Replies
I'm trying to test a trigger that updates the Case Status field, but the assert is failing on Test Class, can anyone help me with this? 

Here is the Test Class
@isTest 
private class AtualizaStatusDoChamadoTest {
    
    private static testmethod void testaTrigger(){
        Case novoCaso = new Case();
        novoCaso.Nome__c = 'Teste';
        novoCaso.Status = 'Em aberto';
        novoCaso.Email__c = 'teste@teste.com';
        insert novoCaso;

        Comentario_caso__c novoComentario = new Comentario_caso__c();
        novoComentario.Caso__c = novoCaso.Id;
        novoComentario.Tipo_de_Comentario__c = 'Encerramento';
        insert novoComentario;   
        
        Case caso = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
        
        Test.startTest();
        System.assertEquals('Encerrado', caso.Status);
        Test.stopTest();
    }
}

Here is the Trigger
trigger AtualizaStatusDoChamado on Comentario_Caso__c (before insert, before update) {
    if(Trigger.isBefore){
        if(Trigger.isInsert || Trigger.isUpdate){
            List<Comentario_Caso__c> listaDeComentarios = trigger.new;
            Comentario_Caso__c novoComentario = listaDeComentarios[0];
            Case casoDoComentario = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
            if(novoComentario.Tipo_de_Comentario__c == 'Encerramento'){
                casoDoComentario.Status = 'Encerrado';
            }    
            System.debug('caso: ' + casoDoComentario);
        }
    }
}

Log
11:52:42:863 EXCEPTION_THROWN [19]|System.AssertException: Assertion Failed: Expected: Encerrado, Actual: Em aberto

On the Trigger, the debug is showing the correct Status, maybe I'm doing something wrong when trying to get the updated Case on Test Class.
Hello,
I can't see Sharing button on detail page of custom record, though i can see it in page layout. my application in lightning.
thanks
Hi Gurus,
 I have a case in which i want to override  standard Edit Button Call A Custom Lignting Component on Record Detail Page
  
  How do i do that?
User-added image
Your help is highly appreciated

Regards,
Fiona
Hi All,

Could you please help me for below scenerio.

Opportunity object has field called "review" and it has 3 picklist values.
there are 4 different fields which needs to be considered to update the field.

1. when al the 4 fields are true then update "review" field = pass

2 When 2 or less field are true then update "review" field= reject

3. when 3 of the fields are true then update "review" field= awaiting.

Thanks in advance 
 
Hello, I have apex class like this:

public class TwilioChatterConversationClass {
public static void ContactPostChatter(Id contactRecordId, string message){  
        if (flag == true){
        flag = false;
        Contact c = [ Select id, name, related_referral__r.ownerid, related_referral__r.name, related_Referral__r.Referral_Account__r.name From Contact Where Id =: contactRecordId];

        ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
        ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
        ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
        ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

        messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
        
        mentionSegmentInput.id = c.related_referral__r.ownerid;
    
//hyperlink        
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ c.id;   
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
linkInput.url = fullFileURL;
linkInput.urlName = c.name;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput; 
//

        messageBodyInput.messageSegments.add(mentionSegmentInput);

 //  textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message + ' To view their record <a href=https://centers.lightning.force.com/'+c.Id+'>click here.</a>' ;
   textSegmentInput.text = 'Referral, "' + c.related_referral__r.name  +  '".         Next of Kin,' + c.name +', has responded to your text: ' + message;
    messageBodyInput.messageSegments.add(textSegmentInput);

        feedItemInput.body = messageBodyInput;
        feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
        feedItemInput.subjectId = c.related_referral__r.ownerid;
        
    
ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
    return;
}
}
}
}

I'm trying test code like this, but it's not covering the class (see screenshot below). Any idea why not?

@isTest
public class TwilioTriggerTest {
@isTest
    static void TwilioTest(){
        contact c = new contact();
        c.lastname = 'Test';
        c.MobilePhone = '123456789';
        c.Responded_to_first_message__c = true;
        insert c;

        TwilioChatterConversationClass.ContactPostChatter(c.id, 'hey');
}}

User-added image
 
Hi,
Here is the usecase.
On Opportunity record, I want to show a Archive button. Onclick of the Archive button a prompt must display “Do you want to Archive the record?” , Cancel and Continue button must be displayed. Onclick of Cancel button the prompt must be closed.
Onclick of the Continue button the status of the record must be updated as ‘Archived’ and the Name of the record must be appended with ‘_Archived’. How can achieve this use case?
I have tried to create a flow and called from Quick action, but in flow i am not able to update a Status field? Does Lightning component required to achieve this case?

Hi all,
I need apex class to get documentlink field called LinkedEntityId.
This is my create task when document upload.
trigger CreateTask on ContentVersion (after insert) 
{

List<Task> insertTask = new List<Task>();
Task newTask = new Task();
for(ContentVersion newCase : Trigger.new)
{
newTask.subject = 'Document Expiration';
newTask.WhatId = newCase.Id;
newTask.ActivityDate = newCase.Expiry_Date__c;
newTask.ownerId = newCase.OwnerId;
newTask.status = 'Not started';
newTask.Priority = 'Normal';
insertTask.add(newTask);
    if(insertTask.isEmpty())
    {
        try{
            
        }catch(DmlException de)
        {
            System.debug(de);
        }
    }

}

I need to assign LinkedEntityId this id to createTask . Trigger -> WhoId.

Is anyone help?
Thanks in advance.
    

Hello, 
I need to pass the OpportunityContactRole (contact id) to a new record's field, which is a contact one. I created a map for the OpportunityContactRole and i am trying to pass that id, when i debug at the MAP i get the values but when i pass the contact id to the field i get the error of attempitng to de-reference a null object. Above is a snippet of my code:
 
map<Id, OpportunityContactRole> oppRoleMap = new map<Id, OpportunityContactRole>([select id, OpportunityId, ContactId, isPrimary from OpportunityContactRole where OpportunityId IN: oppId AND isPrimary = true limit 1]);
            	system.debug('The ROLE MAP IS' + oppRoleMap);//i get the values
                system.debug('RoleMap Values ' +oppRoleMap.values());//i get also the values
                //csconta__Contract__c contr = [select id, csconta__Account__r.id from csconta__Contract__c where csconta__Account__r.id =: opp1.accountId];
                
                for(opportunity opp: oppList){
                
                if(oppMap.containsKey(opp.id)){
                    system.debug('inside first if ' + oppMap.containsKey(opp.id));
                    
                if(opp.StageName == 'Closed Won'){
                    system.debug('IS CLOSED WON? ' +opp.StageName);
                    list<csconta__Contract__c> contrList = [select id, csconta__Account__r.id from csconta__Contract__c where csconta__Account__r.id =: opp.accountId];
                    
                    if(contrList.isEmpty()){
                   csconta__Contract__c contract = new csconta__Contract__c();
                  // contract.csconta__Contract_Name__c = 'Hello' +' Contract';
                   contract.csconta__Contract_Name__c = oppMap.get(opp.id).account.name + ' Contract';
                   contract.csconta__Account__c = opp.AccountId;
                   contract.csconta__Valid_From__c = system.today();
                   contract.csconta__Status__c = 'Open';
                   contract.csconta__Contact__c = oppRoleMap.get(opp.id).ContactId;// seems like its null
                        system.debug('The contact is '+ contract.csconta__Contact__c);
                   createcontrList.add(contract); 
                    }

What can i do to pass the contact id?
Hi Gurus,
How do i  Import Apex Classes Dev Sandbox into Visual Studio Code After successfully doing  SFDX: Authorise Org for my dev org which is a scratch org sandbox, basically I would like to execute my apex unit tests from Visual studio code..but the problem is I see only LWC project got created with project.json file  ..Here is my VSCode

User-added image

Regards,
Fiona
Milestone and Opportunity Object is there , On Opportunity you have custom field called total Amount, if opportunity is inserted with 10000 as total amount, automatically 10 milesstone should be created.
if the amount is 15000, 15 milesstone should be created and so on.
Hello, we have some simple apex code that creates a task record, and the whoid of the task is a Lead. 

My question is: Just as when a regular activity is logged, it automatically posts to chatter with a summary of the activity, I need to do the same here. Specifically, I need it to post to the chatter on the Lead record page. Can this be done?
I need to dynamically fetch the picklist values 
I have a requirement in which when the Billing State is Punjab then a custom checkbox(Exists__c should be true) on Account Object. Billing State is a picklist.
I have used Trigger to update that.
trigger ASCExists on Account (after update) {
    if(trigger.isAfter && trigger.isUpdate){
        for(Account acc:trigger.new){
            if(acc.BillingCountry == 'India' && acc.BillingState == 'Punjab' )
            {
                acc.Exists__c = true ;
                update acc;
            }
        }
    }
}
But I am getting this error as:
Error:Apex trigger ASCExists caused an unexpected exception, contact your administrator: ASCExists: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.ASCExists: line 6, column 1

How to fix this. Can somebody help in this.
Thank you 
This is the code of auto lead conversion and autoLeadConversion is the function.I had written master class so i need specific function to be tested
public class AAAExisting{ 
    public List<wrapLead> wrapLeadList {get; set;}
    public List<Lead> accs {get; set;}
    
    public void ConvertedLeadList(){
       accs = [SELECT Id, Name, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId, Status FROM Lead WHERE IsConverted=true];
   // System.debug(accs);
    }
    
    
    
    public AAAExisting(){
        if(wrapLeadList == null) {
            wrapLeadList = new List<wrapLead>();
            for(Lead a: [select Id, Name, Company, Email, Phone, Status FROM Lead WHERE IsConverted=false]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapLeadList .add(new wrapLead(a));
               // System.debug(wrapLeadList);
            }
        }
    }
       
  
    
       Public void autoLeadConversion(List<Lead> autoLeadConversions) {
       //  List<Lead> autoLeadConversions= new List <Lead>();
           for(Lead lead: autoLeadConversions){
              if (lead.isConverted == false) { //to prevent recursion
       Database.LeadConvert lc = new Database.LeadConvert();
       lc.setLeadId(lead.Id); 
       String oppName = lead.LastName;
       lc.setOpportunityName(oppName);
       LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
       lc.setConvertedStatus(convertStatus.MasterLabel);
       Database.LeadConvertResult lcr = Database.convertLead(lc);
       System.assert(lcr.isSuccess());            
           }
        } 
    }
 
   
    
    public void processSelected() {
        for(wrapLead wrapAccountObj : wrapLeadList ) {
        if(wrapAccountObj.selected == true) {
            Database.LeadConvert lc = new Database.LeadConvert();
           lc.setLeadId(wrapAccountObj.acc.Id);
           lc.setopportunityname(wrapAccountObj.acc.Company);
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            }
            }
             }
 
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapLead{
        public Lead acc {get; set;}
        public Boolean selected {get; set;}
 
        //This is the contructor method. When we create a new wrapAccount object we pass a Account that is set to the acc property. We also set the selected value to false
        public wrapLead(Lead a) {
            acc = a;
            selected = false;
            System.debug('convertStatus'+ acc);
        }

    }
    
}



 
Hi,

I'm trying to insert a negative number but it does not allow me to enter a minus. 

<lightning:input min="-10.0" type="number" formatter="decimal" step = ".01" value="{!v.price}" onchange="{!c.calc}"/>
                                                                
Hello everyone,
My component:
apex:component layout="block" access="global" language="{!lan}" id="ac" >
apex:attribute name="selA" type="String" default="" description="" />
apex:attribute name="SOList" type="map" default="" description="" />

apex:selectList value="{!selA}" size="1 id="aslLinOrgMan" >
apex:selectOption itemValue="" itemLabel="Select" />
/apex:selectList>
What I would like to do is dynamically building the list <apex:selectOption> with the itemValue/itemLabel passed in the SOList map attribute, or through another approach if this is not a good one.
Is there a way to achieve this? If so, how?
Thanks in advance for your support,
All the best,
Jerome
Hi All,

I was referring the salesforce documentation for lightning:input type="email" .There it is mentioned When multiple email is used, the email field expects a single email address or a comma-separated list of email addresses. Example, my@domain.com,your@domain.com with or without a space after the comma.Is it possible to use type="email" when there is a need to enter multiple email id.I have tried to enter multiple emails with comma separation but it is giving me error as "You have entered an invalid format.".
Hi all,

I need something like a clickable image. when I click the image in a page related record should be created.

Thanks in advance.
i show error in this line like Illegal assignment from List<Contact> to List<contact>

list<Contact> lstContacts =[SELECT Id,FirstName, LastName, Email, Phone, accountID FROM Contact Where accountid =: accountRecordID];

Hi, I need to create an account for every exiting contact, could anyone help?
Note: the existing contacts are added from an external app that's why I was able to have contacts without related account.

I need to do it inn execute nonymus window.

Thank you so much!

Hi 
Is it possible to send Email  with  Attachments to the Contact through Batch Apex.
lets explain little bit clear :
Test contact already have File 1 & File2.
So, 
I send to Send Email to ' Test Contact' along with  File1 & File2 ....through Batch Apex.

I am not sure, is it possible or not?
if possible, can some one provide any sample code for this requirment

Thanks
VRK

 
  • February 17, 2021
  • Like
  • 0
trigger ContentDocumentLinkTrigger on ContentDocumentLink (after insert) {
 String tempParentId;
    Set<Id> setParentId = new Set<Id>();
    List<Lead> Leadlst = new List<Lead>();
    
 for (ContentDocumentLink cdl : trigger.new ) {
            tempParentId = cdl.LinkedEntityId;
     
            if (tempParentId.left(3) =='a0X') {
                System.debug('Debug : found a0X');
                System.debug('Debug : content document id ' + cdl.ContentDocumentId );
                setParentId.add(cdl.LinkedEntityId);
            }
        }
    Leadlst = [select Id , HasAttachment__c from Lead where Id IN :setParentId];
     
     For(Lead L : Leadlst)
     {
        L.HasAttachment__c = True;
     }

     update Leadlst;
}
 
Create a custom field called number in account in that field if we enter 5 then automatically 5 records should create in contact using apex trigger.
Hello, I'm trying to create about 400 Opportunity Line Item records on 400 Opportunities via Data Loader and I keep getting this error message:

dlrs_OpportunityLineItemTrigger: System.LimitException: Apex CPU Time Limit Exceeded

I'm an admin and a contractor we worked with before I joined would have written this code. I found the trigger and the class but don't know if there's a way to bypass it to run this data load? Any help would be greatly appreciated. 
I am our orgs admin and I am trying to fix code set up in 2016 by a previous employee. I know very little about apex but I understand my SOQL query is pulling 0 records and I need to solve for that. I am recieving the following emails. Thank you in advance, Ive been working on this for days! 
"OrderTrigger: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object
Class.OrderTriggerHandler.insertOrder: line 21, column 1
Trigger.OrderTrigger: line 4, column 1"


My trigger is very short, i have bolded line 4 per the email error:

trigger OrderTrigger on Order (after insert) {

    if(Trigger.isInsert){
       OrderTriggerHandler.insertOrder(Trigger.new);  
     }

}

My handler is as follows, i have bolded line 21 per error email:
public with sharing class OrderTriggerHandler{

    public Static void insertOrder(List<Order> objOrder)
    {
        
         Set<Id> objAcc = new Set<Id>();
         for(Order objOr : objOrder){
             objAcc.add(objOr.AccountId);
         }
         
         
         List<Contact> objCon = [select id,name,Email,AccountId,Account.Parent.ParentId, Account.Parent.Parent.Name from Contact where AccountId IN : objAcc];
         String partnerName;
         Id wideEmailAddressId;
         if(objCon.size() > 0){
             List<String> objMail = new List<String>();
             Set<String> objSetAcc = new Set<String>();
             for(Contact objContact : objCon){
                 objMail.add(objContact.Email);
                 partnerName = objContact.Account.Parent.Parent.Name;
                 String accId = String.valueOf(objContact.Account.Parent.ParentId).substring(0, 15);
                 objSetAcc.add('New Order Notification'+accId);
             }
             
        for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress where DisplayName='EvoLaw, LLC']) {
             if(owa.Address.contains('CSR')) wideEmailAddressId = owa.id; 
        } 
        System.debug('&&&&&&&objSetAcc&&&&&& '+objSetAcc);
        
        
       List<EmailTemplate> templateId = [Select id,Subject, HtmlValue, Body from EmailTemplate where name IN : objSetAcc];
       System.debug('&&&&&&&templateId&&&&&& '+templateId);
       if(templateId.size() > 0){ 
       
            System.debug('&&&&&&&templateId &&&&& '+templateId[0]); 
           String [] emailsAsArray = new String [objMail.size()];
            Integer i = 0;
            for (String singleCCEmail: objMail) {
                emailsAsArray[i++] = singleCCEmail;
            }  
             
           
           String subject =templateId[0].Subject ;
           String htmlBody = templateId[0].HtmlValue ;
           String plainBody = templateId[0].Body;
         
          
          // Messaging.sendEmail(new Messaging.Singleemailmessage[] {mail});
     @TestVisible Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.toAddresses = emailsAsArray;
            message.optOutPolicy = 'FILTER';
            message.subject = 'Opt Out Test Message';
            //message.plainTextBody = 'This is the message body.';
             if(templateId[0].id != null)
             message.setTemplateId(templateId[0].id);
             if(wideEmailAddressId!=Null)
             message.setOrgWideEmailAddressID(wideEmailAddressId);
             message.setSubject(subject);
             message.setHtmlBody(htmlBody);
             message.setPlainTextBody(plainBody);
            // message.setTreatBodiesAsTemplate(true);
            Messaging.SingleEmailMessage[] messages =  new List<Messaging.SingleEmailMessage> {message};
            System.debug('___________msg____' +messages );
            Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
            if (results[0].success) {
                System.debug('The email was sent successfully.');
            } else {
                System.debug('The email failed to send: '+ results[0].errors[0].message);
            } 
             
           }
         }
    }

}
I'm trying to test a trigger that updates the Case Status field, but the assert is failing on Test Class, can anyone help me with this? 

Here is the Test Class
@isTest 
private class AtualizaStatusDoChamadoTest {
    
    private static testmethod void testaTrigger(){
        Case novoCaso = new Case();
        novoCaso.Nome__c = 'Teste';
        novoCaso.Status = 'Em aberto';
        novoCaso.Email__c = 'teste@teste.com';
        insert novoCaso;

        Comentario_caso__c novoComentario = new Comentario_caso__c();
        novoComentario.Caso__c = novoCaso.Id;
        novoComentario.Tipo_de_Comentario__c = 'Encerramento';
        insert novoComentario;   
        
        Case caso = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
        
        Test.startTest();
        System.assertEquals('Encerrado', caso.Status);
        Test.stopTest();
    }
}

Here is the Trigger
trigger AtualizaStatusDoChamado on Comentario_Caso__c (before insert, before update) {
    if(Trigger.isBefore){
        if(Trigger.isInsert || Trigger.isUpdate){
            List<Comentario_Caso__c> listaDeComentarios = trigger.new;
            Comentario_Caso__c novoComentario = listaDeComentarios[0];
            Case casoDoComentario = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
            if(novoComentario.Tipo_de_Comentario__c == 'Encerramento'){
                casoDoComentario.Status = 'Encerrado';
            }    
            System.debug('caso: ' + casoDoComentario);
        }
    }
}

Log
11:52:42:863 EXCEPTION_THROWN [19]|System.AssertException: Assertion Failed: Expected: Encerrado, Actual: Em aberto

On the Trigger, the debug is showing the correct Status, maybe I'm doing something wrong when trying to get the updated Case on Test Class.
  for (integer v = 0; v < denom.size(); v++) {  
       integer didx = v - 1;  
       integer dval = (integer)Math.pow(1000, v);  
       if (dval > val) {  
         integer mod = (integer)Math.pow(1000, didx);  
          integer l = (integer) val / mod;  
        integer r = (integer) val - (l * mod);  
         String ret = convert_nnn(l) + ' ' + denom[didx];  
         if (r > 0) {  
           ret += ', ' + english_number(r);  
         }  
          return ret;  
        }  
      }  
      return 'Should never get here, bottomed out in english_number';  
    }  
 }

Please help me for test class code covarage for the above code 
Hello,
I can't see Sharing button on detail page of custom record, though i can see it in page layout. my application in lightning.
thanks
I am getting the Null pointer error while keeping Lat invoice generated field blank.
Below is my code:
public class OpportunityTriggerEventHelper {
    
    public static void updateBaseRateOnOpp(Map<Id, Opportunity> oldDRObjMap, List<Opportunity> newDRObjList) {
        //if(checkRecursive.runOnce()){
            
            set<string> frequency = new set<string>();
            set<string> category = new set<String>();
            Set<Id> oppId = new Set<Id>();
            Map<string,Daily_Rate__c> maprate = new Map<string,Daily_Rate__c>(); 
            
            for(Opportunity d : newDRObjList){
                
                if(oldDRObjMap != null && oldDRObjMap.get(d.Id).cfg_LastInvGenDate__c !=d.cfg_LastInvGenDate__c) {
                    category.add(d.cfg_ChildAgeCat__c);
                    
                        oppId.add(d.Id);
                    }
                     }
            
            for(Opportunity opp : [SELECT Id, cfg_Enrollment__r.cfg_Attendance_Frequency__c FROM Opportunity WHERE ID IN :oppId]){
                frequency.add(opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c);
            }
          
            list<Opportunity> oppLst = new list<Opportunity>();
            
            for(Opportunity opp : [SELECT Id, cfg_Enrollment__r.cfg_Attendance_Frequency__c, cfg_ChildAgeCat__c, cfg_LastInvGenDate__c FROM Opportunity WHERE ID IN :oppId]){
                
                for(Daily_Rate__c drObj : [SELECT Id, Attendance_frequency__c, Child_Category__c, Rate__c, Start_Date__c, End_Date__c 
                                           FROM Daily_Rate__c 
                                           WHERE Attendance_frequency__c = :opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c AND Child_Category__c = :opp.cfg_ChildAgeCat__c
                                           AND Start_Date__c <= :opp.cfg_LastInvGenDate__c.addDays(7) AND End_Date__c >= :opp.cfg_LastInvGenDate__c.addDays(7)]){
                                               maprate.put(drObj.Attendance_frequency__c +''+drObj.Child_Category__c, drObj);   
                                           }
            }
            
            
            for(Opportunity opp : [SELECT Id, cfg_Enrollment__r.cfg_Attendance_Frequency__c, cfg_ChildAgeCat__c, cfg_LastInvGenDate__c FROM Opportunity WHERE ID IN :oppId]){
                if(maprate.containsKey(opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c +''+ opp.cfg_ChildAgeCat__c)){
                    
                    if(maprate.get(opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c +''+ opp.cfg_ChildAgeCat__c).Start_Date__c <= opp.cfg_LastInvGenDate__c.addDays(7) && maprate.get(opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c +''+ opp.cfg_ChildAgeCat__c).End_Date__c >= opp.cfg_LastInvGenDate__c.addDays(7))
                        
                        opp.Base_Rate__c = maprate.get(opp.cfg_Enrollment__r.cfg_Attendance_Frequency__c +''+ opp.cfg_ChildAgeCat__c).Rate__c;
                       
                     
                        }
                oppLst.add(opp);
            }
            
            if(!oppLst.isEmpty()){
                update oppLst;    
            }
            
        //}
    }
}
Hi Gurus,
 I have a case in which i want to override  standard Edit Button Call A Custom Lignting Component on Record Detail Page
  
  How do i do that?
User-added image
Your help is highly appreciated

Regards,
Fiona
Need to create a report to provide the average number of Log-a-Call task records per day by Assigned user.
I'm trying to test a trigger that updates the Case Status field, but the assert is failing on Test Class, can anyone help me with this? 

Here is the Test Class
@isTest 
private class AtualizaStatusDoChamadoTest {
    
    private static testmethod void testaTrigger(){
        Case novoCaso = new Case();
        novoCaso.Nome__c = 'Teste';
        novoCaso.Status = 'Em aberto';
        novoCaso.Email__c = 'teste@teste.com';
        insert novoCaso;

        Comentario_caso__c novoComentario = new Comentario_caso__c();
        novoComentario.Caso__c = novoCaso.Id;
        novoComentario.Tipo_de_Comentario__c = 'Encerramento';
        insert novoComentario;   
        
        Case caso = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
        
        Test.startTest();
        System.assertEquals('Encerrado', caso.Status);
        Test.stopTest();
    }
}

Here is the Trigger
trigger AtualizaStatusDoChamado on Comentario_Caso__c (before insert, before update) {
    if(Trigger.isBefore){
        if(Trigger.isInsert || Trigger.isUpdate){
            List<Comentario_Caso__c> listaDeComentarios = trigger.new;
            Comentario_Caso__c novoComentario = listaDeComentarios[0];
            Case casoDoComentario = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c];
            if(novoComentario.Tipo_de_Comentario__c == 'Encerramento'){
                casoDoComentario.Status = 'Encerrado';
            }    
            System.debug('caso: ' + casoDoComentario);
        }
    }
}

Log
11:52:42:863 EXCEPTION_THROWN [19]|System.AssertException: Assertion Failed: Expected: Encerrado, Actual: Em aberto

On the Trigger, the debug is showing the correct Status, maybe I'm doing something wrong when trying to get the updated Case on Test Class.
Hello,

I'm relatively new to SOQL and Conga Query builder and am attempting to query related data of the same object, using a lookup of the current object. Here is how the objects are related:

From the current Custom object, I have a lookup relationship to accounts--the field is Primary Account. I'd like to query all other related objects of the same type as the current object. My statement looks like this so far, however, it is failing.

SELECT Custom_Field1__c, Name FROM Custom__c WHERE Primary_Account__r.Id = Primary_Account__c.Id

Primary_Account__r.Id is the ID of the Master "Primary Account" on the Custom record, but the query doesn't seem to be pulling the Id to match from the current custom object so that the query can pull all related Custom_Field1 and Name fields from the other custom objects related to the Primary Account. I hope this all makes sense.

Thank you in advance.
  • January 15, 2021
  • Like
  • 1