• SalesforceDevil@16
  • NEWBIE
  • 169 Points
  • Member since 2018

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 41
    Replies
Hi Guys,

I am new to developing and needed some assistance in understand this error message which i get when i execute the below mentioned batch to send email notification on daily basis if checkbox is false (Which includes some more conditions :

Requirement 1 : Build a nightly job to send an Email to the Primary Contact Email address on the opportunity if any of the following checkboxes are not checked
Section 1  
Section 2
Section 3
Section 4
Section 5
Requirement 2 : Section 5 is not required for opportunities having a stored date prior to 10/1/2013
Requirement 3 : 
Emails are triggered based on the following:
Enrollment date is < current date && Storage date = Null && DueDate = CurrentDate+14
OR
Enrollment date != Null && Storage date = CurrentDate + 7
global class OpportunityEnrollmentAlert implements Database.Batchable<sObject>,Database.Stateful{
    
APEX Code :
global List <String> emailAdd = new List<String>();
    global final Date DueCheck = Date.newInstance(2013, 10, 1);
    List<Messaging.SingleEmailMessage> mails = new  List<Messaging.SingleEmailMessage>();
    global Database.Querylocator start(Database.BatchableContext BC){
        
        String query = 'SELECT Id, Name, Primary_Contact__c, Primary_Email__c, Enrollment_Date__c, Storage_Date__c from Opportunity where (Section_1_Received__c = FALSE OR Section_2_Received__c = FALSE OR Section_3_Received__c = FALSE OR Section_4_Received__c = FALSE OR Section_5_Received__c = FALSE && objScope.Storage_Date__c > DueCheck)';
        system.debug('query==========>>>>>>>'+query);
        return Database.getQueryLocator(query);
        
    }
    
    global void execute(Database.BatchableContext BC, List<Opportunity> scope){
        system.debug('Inside execute method');
        system.debug('scope=====>>>>>'+scope);
        set<id> oppIdList = new set<id>();
        
        for (Opportunity objScope: scope){
            
            if (objScope.Enrollment_Date__c < Date.Today() && objScope.Storage_Date__c == NULL && objScope.Due_Date__c == Date.Today().addDays(14)){
                System.debug('_------------------Test');
            }
            else if(objScope.Enrollment_Date__c != NULL && objScope.Storage_Date__c == Date.Today().addDays(7)){
            }
            oppIdList.add(objscope.id);
        }
        
        if (oppIdList!= null && oppIdList.size()>0){
            
        }
        
        if(scope!=null || !scope.isEmpty()){
            for(Opportunity opp:scope){
                system.debug('primary contact email'+opp.Primary_Email__c);
                
                // Step 1: Create a new Email
                Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                
                // Step 2: Set list of people who should get the email
                emailAdd.add(opp.Primary_Email__c);
                message.setToAddresses(emailAdd);
                
                // Step 4. Set email contents - you can use variables!
              
                Id etId = [select id, Name from EmailTemplate where developername='Missing_Enrollment_Forms'].id;
                message.setTargetObjectId(opp.Primary_Contact__c);
                message.setTemplateId(etId);
                mails.add(message);    
            }
        }
        // Step 6: Send all emails in the master list
        Messaging.sendEmail(mails);
    }
    global void finish(Database.BatchableContext BC){    
    }
}
Error : 
User-added image

Appreciate all your help.
Hi Friends,

Iam geeting the 'Challenge Not yet complete... here's what's wrong: 
Could not find an Opportunity Stage named 'Awaiting Approval' ERROR message when i do the Check Challenge. I created a SalesProcess 'RB Robotics Sales Process' which is not having the 'Awaiting Approval' stage in the list.  Please see the attached screen shot for the same and help me how can i bring the 'Awaiting Approval' Stage in RB Robotics Sales Process'

Regards,User-added imageUser-added image
Koti
Hello,

I was trying to add a "dashboard filter" in lighning.
I am getting only "date" fields for filter.

What are limitations for dashboard filter ?

Thank you for inputs 
Hello,

I was creating a dashboard filter like in below link:

https://help.salesforce.com/articleView?id=dashboard_filters_editing.htm&type=5

I was not able find a "custom field" which is of text type.
However i can find the few other fields, what can be the reason ? and how can i allow this field to be displayed
 
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: COMMERCE-ERR:For input string: "" faultcode=soapenv:Server faultactor=
Hello All,

I have a related list button in salesforce classic which showing a popup during creation of record.

I want same fuctionality in salesforce lightning but somehow the JS buttons are not working , i have a workaroud but i think that workaroud is not good so can you guyz please guide me.
Hello All, 

Can anyone guide me how to make a custom approval process in salesforce lightning
Hello All,

is it possible when Campaign influence is inserted so update a field on opportunity by using trigger because of i have tried when campaing influence added so trigger is not firing .

 
Hello All,

I want override Opportunity detail page without writing each and every field in lightning component is their any way to do this
Hello All

I need a urgent help regarding to vf page i have a vf page whic is overriding opportunity view so i need to replace it by lightning component or either any workaround for it this is my vf page.
<apex:page id="optyPageId" StandardController="Opportunity" tabStyle="Opportunity" sidebar="true" docType="html-5.0" extensions="ICS_Async_Search_Before_CreateController">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
 <apex:pageMessages id="showmsg" escape="false" rendered="{!MatchResponse!=null && MatchResponse.size!=0}"/>
    <apex:form >
        <apex:actionFunction name="searchCDMController" action="{!searchCDM}" reRender="searchResultOPId,showmsg,dsverif" status="loadingStatus" oncomplete="checkDSVerificationCheck();"/>
        <apex:actionFunction name="rollBackStageController" action="{!rollBackStage}" reRender="optyPageId" status="loadingStatus"/>
        <apex:outputPanel id="searchResultOPId"  styleClass="searchResultOPCls" style="position:absolute;z-index:50101;">
        <apex:outputPanel rendered="{!MatchResponse!=null && MatchResponse.size!=0}" styleClass="matchDialogCls">
        <apex:pageBlock id="matchDialogId"  title="Same Account Found in CDM (Please do not Refresh the page)"  >
        <script>$('.overlayBackground').show();</script>
        
        <apex:pageBlockSection title="CDM Search Result" columns="1" >
                    <apex:pageBlockTable value="{!MatchResponse}" id="matchPgBlkTbl" var="match">
                        <apex:column headerValue="Action">
                            <span> 
                                <input type="radio" name="radio" value="{!match.PartyId}">
                                    <apex:actionSupport event="onclick" action="{!getSelected}" reRender="getCustBtn,custOutPan">
                                        <apex:param name="partyid" value="{!match.PartyId}"/>
                                    </apex:actionSupport>
                                </input>
                            </span>
                        </apex:column>  
                        <apex:column headerValue="Party Id" value="{!match.PartyId}"/>
                        <apex:column headerValue="Registry Id" value="{!match.RegistryId}"/>
                        <apex:column headerValue="Customer Name" value="{!match.CustomerName}"/>
                        <apex:column headerValue="City" value="{!match.City}"/>
                        <apex:column headerValue="State" value="{!match.State}"/>
                        <apex:column headerValue="Province" value="{!match.Province}"/>
                        <apex:column headerValue="Postal Code" value="{!match.PostalCode}"/>
                        <apex:column headerValue="County Code" value="{!match.CountyCode}"/>
                        <apex:column headerValue="Country" value="{!match.Country}"/>
                        <apex:column headerValue="DUNS Number" value="{!match.DUNSNumber}"/>
                        <apex:column headerValue="DataQualityScore" value="{!match.DataQualityScore}"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem rendered="{!MatchResponse!=null && MatchResponse.size!=0}" >
                <apex:commandButton id="getCustBtn" value="Get Customer Details" action="{!getCustomerFromCDM}"  status="loadingStatus" disabled="{!selectedAccountId==null}" style="margin-top:10px;margin-bottom:10px;" reRender="custOutPan"/>
            </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:outputPanel id="custOutPan" >
            <br/>
                    <apex:pageBlockSection title="Customer Details Response from CDM" columns="1" rendered="{!custRes.PartyId!=null}">
                        <apex:pageBlockTable value="{!custRes}" var="cust"> 
                            <apex:column headerValue="PartyId" value="{!cust.PartyId}"/>
                            <apex:column headerValue="RegistryId" value="{!cust.RegistryId}"/>
                            <apex:column headerValue="CustomerName" value="{!cust.CustomerName}"/>
                            <apex:column headerValue="StreetAddress" value="{!cust.StreetAddress}"/>
                            <apex:column headerValue="StreetAddress2" value="{!cust.StreetAddress2}"/>
                            <apex:column headerValue="State" value="{!cust.State}"/>
                            <apex:column headerValue="Province" value="{!cust.Province}"/>
                            <apex:column headerValue="PostalCode" value="{!cust.PostalCode}"/>
                            <apex:column headerValue="CountyCode" value="{!cust.CountyCode}"/>
                            <apex:column headerValue="Country" value="{!cust.Country}"/>
                            <apex:column headerValue="DUNSNumber" value="{!cust.DUNSNumber}"/>

                            <apex:column headerValue="Source">
                                <apex:outputPanel rendered="{!cust.OrigSystemReferences.OrigSystemReference!=null}">
                                    <a class="showMoreCls" onClick="$('.sourceSystemOPCls, .overlayBackground').show()">...</a>
                                </apex:outputPanel>
                                <apex:outputPanel styleClass="custPopUpCls sourceSystemOPCls"  style="display:none">
                                    <a class="closeCls pbTitle" onClick="$('.sourceSystemOPCls, .overlayBackground').hide()">Close</a>
                                    <apex:pageBlock title="Source System References">
                                        <apex:pageBlockTable value="{!cust.OrigSystemReferences.OrigSystemReference}" var="sourceSysRef">
                                            <apex:column headerValue="Referece Id" value="{!sourceSysRef.OrigSystemReferenceId}"/>
                                            <apex:column headerValue="Source System" value="{!sourceSysRef.OrigSystem}"/>
                                            <apex:column headerValue="System Reference" value="{!sourceSysRef.OrigSystemReference}"/>
                                        </apex:pageBlockTable>
                                    </apex:pageBlock>
                                </apex:outputPanel>
                            </apex:column>
                            
                            <apex:column headerValue="PartyUsages">
                                <apex:outputPanel rendered="{!cust.PartyUsages.PartyUsageAssignment!=null}">
                                    <a class="showMoreCls" onClick="$('.partyUsagesOPCls, .overlayBackground').show()">...</a>
                                </apex:outputPanel>
                                <apex:outputPanel styleClass="custPopUpCls partyUsagesOPCls"  style="display:none">
                                    <a class="closeCls pbTitle" onClick="$('.partyUsagesOPCls, .overlayBackground').hide()">Close</a>
                                    <apex:pageBlock title="Party Usages">
                                        <apex:pageBlockTable value="{!cust.PartyUsages.PartyUsageAssignment}" var="usage">
                                            <apex:column headerValue="Referece Id" value="{!usage.PartyUsgAssignmentId}"/>
                                            <apex:column headerValue="Source System" value="{!usage.PartyUsageCode}"/>
                                        </apex:pageBlockTable>
                                    </apex:pageBlock>
                                </apex:outputPanel>
                            </apex:column>
                            
                            
                        </apex:pageBlockTable>
                        <apex:outputPanel >
                        <apex:outputText >Do you want to create the Account in CDM?  Click Here.</apex:outputText>
                        <apex:commandButton styleClass="createAccBtn" value="Create Account in CDM" action="{!updateWonPending}" oncomplete="$('.searchResultOPCls, .overlayBackground').hide();" status="loadingStatus" reRender="showmsg,custOutPan"/>
                        
                        <apex:outputText ><br/><b>OR</b><br/>Do you want to update the Account in SFDC ?  Click Here.</apex:outputText>
                        <apex:commandButton styleClass="createAccBtn" value="Update Account in SFDC" action="{!updateSFDCAccount}" oncomplete="$('.searchResultOPCls, .overlayBackground').hide();" status="loadingStatus" reRender="showmsg,custOutPan"/>
                        
                        </apex:outputPanel>
                    </apex:pageBlockSection>   
    </apex:outputPanel>
              
        
        </apex:pageBlock>
        </apex:outputPanel>
        </apex:outputPanel>
        <!-- <input type="hidden" id="dsverif" value="{!dsVerificationReq}" class="dsverifCls"/> -->
        <apex:outputPanel id="dsverif" styleClass="dsverifCls">
            <apex:inputHidden value="{!dsVerificationReq}"/>
        </apex:outputPanel>

    </apex:form>
    <apex:actionStatus id="loadingStatus">
            <apex:facet name="start">
                <div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.25; z-index: 52000; background-color: black;">
                &nbsp;
                </div>
                <div style="position: fixed; left: 0; top: 0; bottom: 0; right: 0; z-index: 52001; margin: 15% 50%">
                    <div style="display: inline-block; padding: 2px; background-color: #fff; width: 125px;">
                        <img src="/img/loading.gif" style="float: left; margin: 8px;" />
                        <span style="display: inline-block; padding: 10px 0px;">Please Wait...</span>
                    </div>
                </div>
            </apex:facet>
        </apex:actionStatus>
        <apex:outputPanel id="detailPageOPPanel">
            <apex:detail inlineEdit="true" relatedList="true" showChatter="true" oncomplete="searchCDMAJAX();"/>
        </apex:outputPanel>

    <script>
        function searchCDMAJAX(){
            searchCDMController();
        }
        function checkDSVerificationCheck(){
            if($(".dsverifCls>input").val() =='true'){
                alert('{!$Label.DS_Verification_Err_Msg}')
                rollBackStageController();
            }
        }
    </script>
    <style>
    .closeCls{
        background:white;
        float: right;
        width: 30px !important;
        max-width:400px;
        cursor:pointer;
        padding:5px;
    }
    .matchDialogCls .pbTitle{
        white-space: nowrap;
    }
    </style> 
</apex:page>
This is my Vf page i want this in lightning component or any other workaround will be appreciated For how to override opportunity view page without mentioning each field

Thanx regads 
Shubham
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: COMMERCE-ERR:For input string: "" faultcode=soapenv:Server faultactor=
Hi,

I would like to have a 'Close Project' (Custom button) in my 'Project'(Custom Object) record's page layout. When i click the 'Close Project' button, the record type of particular record must change from 'Current' to 'Closed'.

How i should do this? Thanks in advance

Thanks and regards,
Durai
Hello All,

I want override Opportunity detail page without writing each and every field in lightning component is their any way to do this
I have 2 Queues - AsiaQ & EuropeQ. I have a Apex API that converts a Cart Custom Object record into a Lead record. The Lead record has a field callled Region which takes Asia or Europe. Based on the region selected, I want the Lead to be assigned to either AsiaQ or EuropeQ.
 
Below code works: I have hard coded the Q IDs.
ID QID;
Lead indLead = new Lead();

if (indLead.region__c == 'Asia')
      QID = '00G46000000nsXy';
else
    QID = '00G46000000nsY3';

indLead.ownerid = QID;

I dont want to hard code. I want to get the Q ID based on the region in the Lead record.

Below is the code. This is NOT working. Pl. help & suggest what mistake I am doing -

ID QID;
Lead indLead = new Lead();

QID = [select queue.id from QueuesObject where Queue.Name = :indLead.region__c limit 1];
indLead.ownerid = QID;

I have confirmed that :indLead.region__c has the correct value of Asia or Europe.
Hi All,

Please provide any sample code of Batch class to fetch the records based on time and date.

Thanks,
Sarma
I am looking to count records based on various filters and appear like a roll-up just using Flows instead of the Roll-Up Helper
I have two objects one is a standard object i.e Account and the other one is a custom object and their have a look up relations .I have  created 3 text fields as A,B,C in  custom object.Now when I concatenate b/w A and B , the result should get displayed in C.when u type the value manually in field C ,it should throw the error.So which type of trigger is used and how wil u write the code?
Hello folks,

i am not very experienced with coding, but I just want to create a very simple record creation functionality with the event "e.force:createRecord".
I have the following plan:

I want to create a button on the task layout to create a new task record that is partly based on the present task.
Its basically a follow up task were I just want to take over some field values like whoid and whatid to
save some time for users. If users click the button a record creation window is opening with some default values that
can be changed if needed.

Here is my code:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId"
                access="global">
    
	<aura:attribute name="record" type="Object"/>
	<aura:attribute name="simpleRecord" type="Object"/>
	<aura:attribute name="recordError" type="String"/>
    
    <aura:attribute name="taskfields" type="Object"/>
    
    <force:recordData aura:id="recordLoader"
        recordId="{!v.recordId}"
        targetRecord="{!v.record}"
        layoutType="FULL"
        targetFields="{!v.simpleRecord}"
        targetError="{!v.recordError}"
        fields="Id, Name, WhoId, Description, WhatId"
        />
    
    <lightning:button label="Erstelle Folgeaufgabe" variant="brand" onclick="{!c.createFollowUpTask}"/>
    
</aura:component>
 
({
 createFollowUpTask: function (component) {
        var createRecordEvent = $A.get('e.force:createRecord');
     	var recordId = component.get("v.recordId");
     	var simpleRecord = component.get("v.simpleRecord");
        if ( createRecordEvent ) {
            createRecordEvent.setParams({
                'entityApiName': 'Task',
                'defaultFieldValues': {
                    'Subject' : 'tasksubject',
                	'WhoId' : simpleRecord.WhoId,
                }
            });
            createRecordEvent.fire();
        } else {
            /* Create Record Event is not supported */
            alert("Task creation not supported");
        }
    }
})

Now I have two problems:

- I get error messages if the who or whatid is not populated
- I sometimes get the same error messages​​​​​​ even if the who and whatid is populted
- I actually want to open the component with a quick action button instead of a lightning button (lightning:button and onclick), but I just get a "window in window"

User-added image

Quick Action Error - window in window

Can someone help me please with that probably simple issue? Thanks a lot in advance!
@AuraEnabled
    public static list<batch__c> SaveBatchDet(integer QliRowNum,list<Batch__c> Bt,map<integer,list<batch__c>> Rowmap,string QuoteID){
          system.debug(QliRowNum+'-------------'+Bt+'@@@@@@@@@@@@@@@@'+Rowmap+'###################'+QuoteID); 
         System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
        //transient List<Integer> sortkey=new List<Integer>();
         Map<Integer,list<batch__c>> batchMap =  New Map<Integer,list<batch__c>>();
            batchMap.put(Integer.valueOf(QliRowNum),Bt);
         transient List<Batch__c> batchListToInsert =new List<Batch__c>();
        
         Map<integer,quote_line_item__c> qouteLineItemMap = new Map<integer,quote_line_item__c>();
		for(quote_line_item__c t: [SELECT QliRowNum__c, Id FROM quote_line_item__c WHERE quote1__c=:QuoteID])
         qouteLineItemMap.put(Integer.valueOf(t.QliRowNum__c), t);
        
        transient List<Integer> sortkey=new List<Integer>();
        sortkey.addAll(qouteLineItemMap.keySet());
      for(integer qli:sortkey){
          if(batchMap.get(qli)!=null)
            for(Batch__c bat: batchMap.get(qli)){
                if(bat.Asked_Qty__c!=null && bat.Asked_Qty__c!=''){
                bat.Quote_Line_Item__c=qouteLineItemMap.get(qli).id;
                }
                if(bat.Quote_Line_Item__c!=null)
                batchListToInsert.add(bat);
               // system.debug(batchListToInsert);
            }//End of for 
        }// End of for
        // Inserting the list of batches
        try{
        
          upsert batchListToInsert ;
           System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
            //system.debug(batchListToInsert);
        }catch(DmlException de){
            return null;
        }
        return null;
    }

i am getting error in this query 
 
for(quote_line_item__c t: [SELECT QliRowNum__c, Id FROM quote_line_item__c WHERE quote1__c=:QuoteID])
is there is any workaround to solve this issue?

Could some help me is there is any wrong in my code?

 

Hello

 

I am adopting sfdx. And development was quite easy and straightforward. But the problem take it place when I've started to use packages. A version and package itself are both created successfully as well as deployed and executed. But I'm not able to make any change in my production org even though the package's type is Unlocked. An error message saying me that "managed installed class cannot be saved"

So..What's my problem and what's my option to do here?

Dear Community, I need your help,
I have created a lightning component and I wanted to display it in Opportunity new page. So for that, I override the "New" button on Opportunity for Mobile with a lightning component.
When a user clicks on the "New" button in salesforce one app,  After the user picks the record type. It does not going to lightning component page. 
We strongly need a lightning component page as salesforce mobile style. What can we do?
 
Hi everyone,

i am trying to write the testclass on below class.  some one help me on the test class. I have tried the below given test class but got 0% coverage



public class Trendingfeedbackiconextension{
 
    
    public Id RecordId{get;set;}       
    public String param1 { get; set; }
    public String buttonText{get;set;}
    public string reportComponentName{get;set;}
    public string reportComponentUniqueName{get; 
            set {
            reportComponentUniqueName = value;
            Trendingfeedbackhelperextensionmethod();
            }}
              
    Map<String,Integer> likedislikeCountMap = new Map<String,Integer>();
     
    public pagereference likeDislikemethod(){
     likedislikeCountMap.clear();
    RecordId= Apexpages.currentPage().getParameters().get('id');
    
    System.debug('@@'+RecordId);   
         system.debug('reportComponentUniqueName==>'+reportComponentUniqueName );
        system.debug('reportComponentName==>'+reportComponentName);
        string value= Apexpages.currentPage().getParameters().get('param1');
        system.debug('param1==>'+param1);  
        string componentName = param1.split('-')[0];
        string actionName = param1.split('-')[1];  
        system.debug('componentName==>'+componentName);    
        system.debug('actionName==>'+actionName);    
        //sentdata= Userinfo.getUserId();
        system.debug('@@'+value);
        list<Feedback__c> flist= new list<Feedback__c>();
        Feedback__c f=new Feedback__c();
        flist=[select id,Name,Action__c,User__c,Comment__c from Feedback__c where Name=:componentName And ((Action__c='Like' Or Action__c='Dislike') And User__c=:Userinfo.getUserId()) And AccountId__c=:RecordId];
        system.debug('@@'+flist);
        if(flist.size()== 0){
            system.debug('@@'+flist.size());
            f.Action__c = actionName;
            //sendAction = f.Action__c;
            f.Name = componentName;
            f.AccountId__c=RecordId;
            f.Comment__c=buttonText;
            f.User__c = UserInfo.getUserId();
            system.debug('f===>'+f);
            insert f;

        }
        else {
            system.debug('elseenter');
            for(Feedback__c f2:flist){
                f2.Action__c = actionName;
                f2.Comment__c= buttonText;
              /*  if(f2.Action__c == 'Like'){
                    system.debug('@@'+likedata);
                    system.debug('@@'+dislikedata);
                    likedata =True;
                    dislikedata = false;

                }
                else if(f2.Action__c == 'Dislike'){
                    likedata =false;
                    dislikedata = true;

                }*/

            }
            update flist;
            Trendingfeedbackhelperextensionmethod();
        }
         buttonText='';
        return null;

    }


    

    public void Trendingfeedbackhelperextensionmethod(){ 

     RecordId= Apexpages.currentPage().getParameters().get('id');   
     System.debug('@@'+RecordId);   
       
        system.debug('method enter');
        system.debug('reportComponentUniqueName==>'+reportComponentUniqueName );
        system.debug('reportComponentName==>'+reportComponentName);
        system.debug('@@'+RecordId);
        //list<AggregateResult> results = [select count(Id) Quantity,Action__c FROM Feedback__c WHERE Name In('AORT1','AORT2') GROUP BY  Action__c];        
        list<AggregateResult> results = [select count(Id) Quantity,Action__c FROM Feedback__c WHERE Name =:reportComponentUniqueName and AccountId__c=:RecordId GROUP BY  Action__c having Action__c='Like' OR Action__c='Dislike'];        

        system.debug('@@'+results);
        for(AggregateResult ar : results){
            system.debug('@@'+results);            
            likedislikeCountMap.put((string)ar.get('Action__c'), (integer)ar.get('Quantity'));
            system.debug('@@'+likedislikeCountMap); 
        
       getLikeCount();
       getDislikeCount();
        

        }              

    }
   
    public Trendingfeedbackiconextension(){
   Trendingfeedbackhelperextensionmethod();    
       //system.debug('method enter');
    }
        
/*

        //list<AggregateResult> results = [select count(Id) Quantity,Action__c FROM Feedback__c WHERE Name In('AORT1','AORT2') GROUP BY  Action__c];        
        list<AggregateResult> results = [select count(Id) Quantity,Action__c FROM Feedback__c WHERE Name ='AccountOrganizationRevenueTrend' GROUP BY  Action__c];        

        system.debug('@@'+results);
        for(AggregateResult ar : results){
            system.debug('@@'+results);            
            likedislikeCountMap.put((string)ar.get('Action__c'), (integer)ar.get('Quantity'));
            system.debug('@@'+likedislikeCountMap); 
        }
    
    }*/

     public Integer getLikeCount(){
        if(likedislikeCountMap.get('Like') == null) {
        system.debug('like');
            return 0;
        } 
        return likedislikeCountMap.get('Like');
        
        
    }  
    public Integer getDislikeCount(){
    
        if(likedislikeCountMap.get('Dislike') == null) {
        system.debug('Dislike');
            return 0;
        }
        return likedislikeCountMap.get('Dislike');
    }


    public PageReference Save() {
    string value2= Apexpages.currentPage().getParameters().get('param2');
        string componentName = value2.split('-')[0];
        string actionName = value2.split('-')[1];
        list<Feedback__c> f=new list<Feedback__c>();
        Feedback__c fb=new Feedback__c();
        fb.Action__c=actionName;
        fb.Name=componentName;    
        fb.Comment__c=buttonText;
        fb.AccountId__c=Apexpages.currentPage().getParameters().get('id');
        fb.User__c=userinfo.getuserid();
        f.add(fb);
        insert f; 

        buttonText='';
        return null;
       }




}

Test class:

@isTest
public class TrendingfeedbackiconextensionTest {
    
private static testMethod void trendingfeedbacktest() {

    //list<Feedback__c> f1 = new list<Feedback__c>();
    Feedback__c f2 = new Feedback__c();
    f2.AccountId__c = 'testid';
    f2.Action__c = 'Like';
    f2.Comment__c = 'testcomment';
    f2.User__c = UserInfo.getUserId();
   // f1.add(f2);
    insert f2;
    
    f2.Action__c= 'Dislike';
    
    Update f2;
  
   
    
}
}


Regards,
Isha
I need to convert my trigger into isInsert and isUpdate.
Trigger :

trigger GenerateTimeZone on Lead (before insert,before update) {
    List<Timezone_Setup_Data__mdt> TimezoneSetupList = [SELECT State__c,TimeZone__c FROM Timezone_Setup_Data__mdt];
    if ( TimezoneSetupList != null && !TimezoneSetupList.isEmpty() ){
        Map<String, String> timeZoneMap = new Map<String, String>();
        for(Timezone_Setup_Data__mdt convertToMap : TimezoneSetupList){
            timeZoneMap.put(convertToMap.State__c,convertToMap.TimeZone__c);
        }
        for(Lead leadRec:Trigger.New){
            if(leadRec.Borrower_AddressState__c != NULL){
                if(timeZoneMap.containsKey(leadRec.Borrower_AddressState__c)){
                    leadRec.Lead_Timezone__c = timeZoneMap.get(leadRec.Borrower_AddressState__c);
                }
            }
            else if(leadRec.Property_State__c != NULL){
                if(timeZoneMap.containsKey(leadRec.Property_State__c)){
                    leadRec.Lead_Timezone__c = timeZoneMap.get(leadRec.Property_State__c);
                }
            }
            else{
                   leadRec.Lead_Timezone__c='PST';
            }
        }
    } 

}
Hi Guys,

I am new to developing and needed some assistance in understand this error message which i get when i execute the below mentioned batch to send email notification on daily basis if checkbox is false (Which includes some more conditions :

Requirement 1 : Build a nightly job to send an Email to the Primary Contact Email address on the opportunity if any of the following checkboxes are not checked
Section 1  
Section 2
Section 3
Section 4
Section 5
Requirement 2 : Section 5 is not required for opportunities having a stored date prior to 10/1/2013
Requirement 3 : 
Emails are triggered based on the following:
Enrollment date is < current date && Storage date = Null && DueDate = CurrentDate+14
OR
Enrollment date != Null && Storage date = CurrentDate + 7
global class OpportunityEnrollmentAlert implements Database.Batchable<sObject>,Database.Stateful{
    
APEX Code :
global List <String> emailAdd = new List<String>();
    global final Date DueCheck = Date.newInstance(2013, 10, 1);
    List<Messaging.SingleEmailMessage> mails = new  List<Messaging.SingleEmailMessage>();
    global Database.Querylocator start(Database.BatchableContext BC){
        
        String query = 'SELECT Id, Name, Primary_Contact__c, Primary_Email__c, Enrollment_Date__c, Storage_Date__c from Opportunity where (Section_1_Received__c = FALSE OR Section_2_Received__c = FALSE OR Section_3_Received__c = FALSE OR Section_4_Received__c = FALSE OR Section_5_Received__c = FALSE && objScope.Storage_Date__c > DueCheck)';
        system.debug('query==========>>>>>>>'+query);
        return Database.getQueryLocator(query);
        
    }
    
    global void execute(Database.BatchableContext BC, List<Opportunity> scope){
        system.debug('Inside execute method');
        system.debug('scope=====>>>>>'+scope);
        set<id> oppIdList = new set<id>();
        
        for (Opportunity objScope: scope){
            
            if (objScope.Enrollment_Date__c < Date.Today() && objScope.Storage_Date__c == NULL && objScope.Due_Date__c == Date.Today().addDays(14)){
                System.debug('_------------------Test');
            }
            else if(objScope.Enrollment_Date__c != NULL && objScope.Storage_Date__c == Date.Today().addDays(7)){
            }
            oppIdList.add(objscope.id);
        }
        
        if (oppIdList!= null && oppIdList.size()>0){
            
        }
        
        if(scope!=null || !scope.isEmpty()){
            for(Opportunity opp:scope){
                system.debug('primary contact email'+opp.Primary_Email__c);
                
                // Step 1: Create a new Email
                Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                
                // Step 2: Set list of people who should get the email
                emailAdd.add(opp.Primary_Email__c);
                message.setToAddresses(emailAdd);
                
                // Step 4. Set email contents - you can use variables!
              
                Id etId = [select id, Name from EmailTemplate where developername='Missing_Enrollment_Forms'].id;
                message.setTargetObjectId(opp.Primary_Contact__c);
                message.setTemplateId(etId);
                mails.add(message);    
            }
        }
        // Step 6: Send all emails in the master list
        Messaging.sendEmail(mails);
    }
    global void finish(Database.BatchableContext BC){    
    }
}
Error : 
User-added image

Appreciate all your help.
Hi All,
my controller is given below:-
public class SocialCasePushTopicController {
    public static void createPushTopic(){
        PushTopic pushTopic = new PushTopic();
        pushTopic.Name = 'CaseUpdates1';
        pushTopic.Query = 'SELECT Id, CaseNumber, Status FROM Case WHERE recordTypeId = \'01241000001USrEAAW\'';
        pushTopic.ApiVersion = 36.0;
        pushTopic.NotifyForOperationCreate = true;
        pushTopic.NotifyForOperationUpdate = true;
        pushTopic.NotifyForOperationUndelete = true;
        pushTopic.NotifyForOperationDelete = true;
        pushTopic.NotifyForFields = 'Referenced';
        insert pushTopic;
    }
    
}
when i write the test class its showing me this error:-System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, A PushTopic with this name already exists. Please choose a different name.: []
my test class is given below:-
@isTest
private class SocialCasePushTopicControllerTest {
   static Testmethod void createPushTopicTest(){
         SocialCasePushTopicController.createPushTopic();
    }
}
Aany suggestions?