• sakthidharan Ambayiram
  • NEWBIE
  • 70 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 10
    Replies
@isTest
global class CQP_ClsTriggerOpportunityHttpResGen implements HttpCalloutMock{

    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {      
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
		res.setBody('{"TYPE":"type","SAPID":"1234"","NUMBER":"100","MESSAGE":"message","LOG_NO":"log_no","LOG_MSG_NO":"100","MESSAGE_V1":"msg1","MESSAGE_V2":"msg2","MESSAGE_V3":"msg3","MESSAGE_V4":"msg4","PARAMETER":"param","ROW":"row","FIELD":"field","SYSTEM":"system"}');
        res.setStatusCode(200);
        res.setStatus('OK');
        return res;
    }
}

***************main class ****************
List<Object> results = (List<Object>) JSON.deserializeUntyped(res.getBody());
for (Object mp: results) {
System.debug('>>'+(Map<String, Object>)mp); 
Map<String, object> jsonRespMap = (Map<String, Object>)mp;
Boolean result = Boolean.valueof(jsonRespMap.get('success'));
if(result == true){
afterUpdateSuccess(opty1);
}

Error details:
Error MessageSystem.JSONException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries at [line:1, column:31]
Stack TraceClass.System.JSON.deserializeUntyped: line 11, column 1
I created a new community page in salesforce which has visualforce page in it. i tried to pass the recordid in the url when i try to hit the page with this url

VF Page: createquotefromopp
Community Page : createquotefromopp

Community page url --> https://ctest.force.com/partners/s/createquotefromopp?id=0063Y0000116xGh
 
but when the community page loading visualpage(in community page) is not taking the id from the url.
please let me know if you have any solutions for this
I am new to lightning, not able to find the root cause
Issue 1: eventhough populated the Due date ,reminder date is read only
Issue 2. On click of create task button, getting the bloe error.
PFB code.

*****************component********************
<aura:component controller="ToDoController" implements="flexiPage:availableForAllPageTypes">  
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="toDoColumns" type="List" />
    <aura:attribute name="toDoData" type="Object" />
    <aura:attribute name="today" type="date" />
    <aura:attribute name="objToDo" type="ToDo__c" default = "{'sObjectType' : 'ToDo__c'}"/>
    <lightning:card title="Add New Task" >
       <aura:set attribute="actions">
            <lightning:buttonicon iconName="utility:chevrondown" alternativeText="down icon" onclick="{!c.toggleForm}"/>
        </aura:set> 
        <div aura:id="form" class="slds-size_1-of-1 slds-p-around_medium">
        <lightning:textarea type="String"
                            label="Task Description" 
                            value="{!v.objToDo.Description__c}"
                            required="true"
                            messageWhenValueMissing="Enter Description" />
         <lightning:input type="Date"
                         label="Due Date"
                         value="{!v.objToDo.Due_Date__c}"
                         required="true"
                         messageWhenValueMissing="Enter Due Date"
                         min="{!v.today}"
                         onChange="{!c.setMaxValueOfReminderDate}" />
        <Lightning:input aura:id="ReminderDate"
                         disabled="true"
                         type="Date"
                         label="Reminder Date"
                         value="{!v.objToDo.Reminder_Date__c}"
                         min="{!v.today}" />
        <lightning:button class="slds-m-top_small"
                          label="Create Task"
                          variant="brand"
                          onclick="{!c.saveToDo}" />
        </div>
        <lightning:datatable keyField="Id"
                             columns="{!v.toDoColumns}"
                             data="{!v.toDoData}"
                             hideCheckboxColumn="true" />
    </lightning:card>
</aura:component>
****************************controller*****************************
({
    doInit : function(component, event, helper) {
        var now = new Date();
        var date = now.getDate();
        var month = now.getMonth() + 1;
        var fullYear = now.getFullYear();
        var today = fullYear + '-' + month + '-' + date;
        component.set("v.today",today);
        component.set("v.toDoColumns",[
            {
                label: 'Description',
                fieldName: 'linkToRecord',
                type: 'url',
                typeAttributes:{label:{fieldName: 'Description__c'},target: '_blank'}
            },
            {
                label: 'Due Date',
                fieldName: 'Due_Date__c',
                type: 'date',
                typeAttributes:{day:'2-digit',month:'long',year:'2-digit'}
            },
             {
                label: 'Reminder Date',
                fieldName: 'Reminder_Date__c',
                type: 'date',
                typeAttributes:{day:'2-digit',month:'long',year:'2-digit'}
            }
        ]);
       // helper.getData(component,event,helper);
    },
    toggleForm : function(component, event, helper) {
        var evesource = event.getSource();
        if(evesource.get("v.iconName") == 'utility:chevrondown'){
            evesource.set("v.iconName",'utility:chevronright');
        }else{
            evesource.set("v.iconName",'utility:chevrondown');
        }
            $A.util.toggleClass(component.find("form"),'slds-hide');
    },
    saveToDo : function(component, event, helper) {
        var objtodo = component.get("v.objToDo");
        var action = component.get("c.SaveRecord");
        action.setParams({
            ToDoRecord : objtodo
        });
        action.setCallback(this,function(response){
            var successstate = response.getState();
            if(successstate ==     "SUCCESS"){
                var toastref = $A.get("e.force:showToast");
                if(response.getReturnValue() == null){
                    toastref.setParams({
                        "type" : "Success",
                        "title" : "Success",
                        "message" : "New Task is Created.",
                        "mode" : "dismissible"
                    });
                }
                    else{
                        toastref.setParams({
                            "type" : "Error",
                            "title" : "Error",
                            "message" : response.getReturnValue(),
                            "mode" : "sticky"
                        }); 
                    }
                    toastref.fire();  
            }
        });
        $A.enqueueAction(action);  
    },
     setMaxValueOfReminderDate : function(component, event, helper) {
        var DueDate = event.getSource().get("v.value");
         component.find("ReminderDate").set("v.value",'');
         if(DueDate != null && DueDate != ''){ 
             alert("disabled");
          component.find("ReminderDate").set("v.disabled",false);  
          component.find("ReminderDate").set("v.max",DueDate);
         }
         else{
             component.find("ReminderDate").set("v.disabled",true);
         }
    }
})
I am new to lightning . I am getting the below error

"This page has an error. You might just need to refresh it.
Error in $A.getCallback() [Component is not defined]
Callback failed: apex://getAccountList/ACTION$getAllAccounts
Failing descriptor: {c:AccList}"

My Code:
****************Apex class****************
public class getAccountList {
    @AuraEnabled
    public static List<Account> getAllAccounts(){
        return[select Id,Name,Type,Phone from Account ];
    }
     @AuraEnabled
    public static List<Account> getFilterAccounts(){
        return[select Id,Name,Type,Phone from Account where Type='Prospect'];
    }
}
************COMPONENT************************
<aura:component controller="getAccountList" >
    <aura:attribute name="AccList" type="List" />
    <aura:attribute name="PaginationList" type="Account[]" />
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="Pagesize" type="Integer" default="10" />
    <aura:attribute name="Totalsize" type="Integer" />
    <tr><ui:inputSelect aura:id="records" >
        <ui:inputSelectOption text="10" value="10"/>
        <ui:inputSelectOption text="20" value="20"/>
        <ui:inputSelectOption text="30" value="30"/>
    </ui:inputSelect></tr>
    <table>
        <thead>
            <th>Id</th>
            <th>Name</th>
            <th>Phone</th>
            <th>Type</th>
        </thead>
     <tbody>
            <aura:iteration items="{! v.AccList}" var="Acc" >
                <tr>
                    <td>{! Acc.Id}</td>
                    <td>{! Acc.Name}</td>
                    <td>{! Acc.Phone}</td>
                    <td>{! Acc.Type}</td>
                    <td><c:Menu testRecord="{! Acc.Id}"/></td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>
********************Controller*******************
({
    doInit : function(component, event, helper){
        helper.callServerMethod(component,"c.getAllAccounts","v.AccList");    
       
    }

})
*******************Helper*****************************
({
    callServerMethod : function(component,methodName,attributeName) {
    var Pagesize = component.get("v.Pagesize");
    var methodRef = component.get(methodName);
        methodRef.setCallback(this,function(response){
            if(response.getState()=="SUCCESS"){
                component.set(attributeName,response.getReturnValue());
            }else{
                alert("Problem in method call");
            }
            Component.set("v.Totalsize",component.get(methodName).length);
            var PaginationList = [];
            for(var i=0;i<Pagesize;i++)
            {
                PaginationList.push(response.getReturnValue()[i]);
            }
            component.set("v.PaginationList",PaginationList);
        });
        $A.enqueueAction(methodRef);
    }    
})
In setup quick find box update reminders under opportunity and i enabled the update reminders and below that i can see the reminders created for the users and activated for some of the users 
here my question is how to create a reminder for the users.
once i done with that it should come under the update reminder settings section in the page 
plz help me ASAP
Scenario: To count the the total cases in the account whenever creating a new case and up[date the case count field in account object through trigger and class
Issue: Case Count field is not updated in account record when the new case getting created 

trigger newCaseInsert on Case (after insert) {
    for(Case cs: trigger.new)
    getCaseCount.getupdatedCount(cs.Account.id);
    }

public class getCaseCount {
     public static Integer CountValue;
     public static Integer getupdatedCount(String AccountId){
         CountValue =[Select COUNT() from Case where Account.id=:AccountId];
         List<Account> record= [Select id,Name,Case_Count__c from Account where Account.id=:AccountId];
         for(Account acts: record){
           acts.Case_Count__c=CountValue;
         }
         update record;
         return CountValue ; 
    }  
}
Error:Apex trigger Test caused an unexpected exception, contact your administrator: Test: execution of AfterUpdate caused by: System.StringException: Invalid id: Dickenson Mobile Generators: Trigger.Test: line 8, column 1
Scenario: whenever the stage field changed to Close won in opportunities , a new object record (Litrack__c)should be created.
Code:
trigger Test on Opportunity (after update) {
    Map<Id,Litrack__c> LitInsert= new Map<Id,Litrack__c>();
    for(Opportunity opNew: Trigger.new){
        for(Opportunity opOld: Trigger.old){
            if(opNew.StageName!=opOld.StageName && opNew.StageName=='Closed Won'){
                Litrack__c Record = new Litrack__c();
                Record.Name=opNew.id;
                Record.Opportunity_Lookup__c=opNew.Name;
                LitInsert.put(Record.id,Record);
            }
        }
      
                insert LitInsert.values();
             
}
}
For example i want to count the records in opportunity for the conditions like type='New customer' and StageName='Prospecting' in a single query?
plz reply back with your answers, thanks in Advance
Hi all,

Error: This page has an error. You might just need to refresh it.
Error in $A.getCallback() [response.getReturnValue is not a function]
Callback failed: apex://getAccountList/ACTION$getFilterAccounts
Failing descriptor: {c:AccList}

**************component
<aura:component controller="getAccountList">
    <aura:attribute name="AccList" type="List" />
    <lightning:button label="Get All Filter Accounts" onclick="{! c.getFilterAccountss}" />
    <aura:iteration items="{! v.AccList}" var="Acc" >
        <tr>
            <td>{! Acc.Id}</td>
            <td>{! Acc.Name}</td>
            <td>{! Acc.Phone}</td>
            <td>{! Acc.Type}</td>
        </tr>
    </aura:iteration>
</aura:component>
********************apex class
public class getAccountList {
   
     @AuraEnabled
    public static List<Account> getFilterAccounts(){
        return[select Id,Name,Type,Phone from Account where Type='Prospect'];
    }

}
************************controller
({
    getFilterAccountss : function(component, event, helper) {
        var accRef = component.get("c.getFilterAccounts");
        accRef.setCallback(this,function (response){
           var response = response.getState(); 
            if(response=="SUCCESS"){
                //alert("Success");
                  component.set("v.AccList",response.getReturnValue());
            }else{alert("No Response")}
        });
        $A.enqueueAction(accRef);
    }
   
})

please help me to resolve this issue
Apex Class
/*
Having the Utilities of the Askiiris Integration
*/
public without Sharing class Integration_Util {
    Public Static FINAL String DML_ERROR='Error Occured While Saving Record To database';
    /*
Method to log the integration trace in notes
*/
    Public Static void InsertNote(id parentId,string body,string title,boolean isPrivate,boolean ExceptionOccured){
        note resp = new note();
        resp.parentId = parentId; 
        resp.body =body; 
        resp.title = title; 
        resp.isPrivate = isPrivate; 
        database.insert(resp,false); 
    }
     /*
Method to send the Exception Email to CMSO-PS
*/
    public static void sendExceptionEmail(String[] emailId,String subject,String emailBody){
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setToAddresses(emailId); 
        semail.setSubject(subject); 
        semail.setHtmlBody(emailBody); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}); 
    } 
    /*
Method to get the Integration Credentials
*/
    Public Static CredentialsWrapper getCredetials( String credentialDevName){
        Integration_Credentials_Mapping__mdt mdt=[select id,Production_End_point_URI__c,Sanbox_End_point_URI__c,
                                                  Sandbox_password__c,Sandbox_user_name__c,Production_password__c,
                                                  Production_user_name__c,security_hns__c,Suffix_URL_1__c,Suffix_URL_2__c,
                                                  Sandbox_Auth_URI__c,Production_Auth_URI__c
                                                  From Integration_Credentials_Mapping__mdt 
                                                  where DeveloperName=:credentialDevName LIMIT 100];
        
        boolean isSandbox=[SELECT issandbox from organization LIMIT 1].isSandbox;
        CredentialsWrapper credwrap=new CredentialsWrapper();
        if(isSandbox){
            credwrap.enpointUrl=mdt.Sanbox_End_point_URI__c;
            credwrap.username =mdt.Sandbox_user_name__c;
            credwrap.password =mdt.Sandbox_password__c;
            credwrap.authTokenUrl =mdt.Sandbox_Auth_URI__c; 
        }else{
            credwrap.enpointUrl=mdt.Production_End_point_URI__c;
            credwrap.username=mdt.Production_user_name__c;
            credwrap.password=mdt.Production_password__c;
            credwrap.authTokenUrl =mdt.Production_Auth_URI__c; 
        }
        credwrap.hnsUrl=mdt.security_hns__c;
        credwrap.isSandbox=isSandbox;
        credwrap.suffixUrl1=mdt.Suffix_URL_1__c;
        credwrap.suffixUrl2=mdt.Suffix_URL_2__c;
        
        return credwrap;
    } 
    /*
Wrapper class used wrap the Integration Credentials
*/
    Public without sharing class CredentialsWrapper{
        Public String username;
        Public String password;
        Public String enpointUrl;
        Public String hnsUrl;
        public Boolean isSandbox;
        Public String suffixUrl1;
        public String suffixUrl2;
        Public String authTokenUrl;
        
    }
    
}

My Test Class

@isTest
public class Integration_Util_UT {

    private static testmethod void InsertNote() {
    Integration_Util.InsertNote('00300000003T2PGAA0','hello','hello',True,True);
     }                    
                    
    private static testmethod void sendExceptionEmail() {
        Integration_Util.sendExceptionEmail('fdgd@df.com','hello','hello');
       }                
                    
    private static testmethod void getCredetials() {
        Integration_Util.getCredetials('hello');
        }                    
}                

My error : "Method does not exist or incorrect signature: void sendExceptionEmail(String, String, String) from the type Integration_Util"
Also the current code coverage is 31%, please hep me to get code coverage 
Thanks in advance
Hi all ,
getting the below eeror while excuting batch
Line: 2, Column: 10
Method does not exist or incorrect signature: void executeBatch(CustomerProcessingBatch) from the type Database

Executing the below code in Anonymous window 

CustomerProcessingBatch objectClass=new CustomerProcessingBatch();
Database.executeBatch(objectClass);

ApexClass:
global class CustomerProcessingBatch implements Database.Batchable<sObject>
{
    global String[] email=new string[] {'a.sakthidhn@gmail.com'};
    //start method
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
       return Database.getQueryLocator('select id,name,Customer_Status__c,Customer_Description__c from Apex_Customer__c where Active__c=true');
    }
    //execute
    global void execute(Database.BatchableContext BC,List <sObject> scope)
    {
        List<Apex_Customer__c> CustomerList=new List<Apex_Customer__c>();
        for(sObject objscope: scope)
        {
            Apex_Customer__c newobjscope=(Apex_Customer__c)objscope;
            newobjscope.Customer_Description__c='Records updated via Batch Job';
            newobjscope.Customer_Status__c='Paid';
            CustomerList.Add(newobjscope);
            system.debug('Records Updated' +CustomerList);
        }
        if(CustomerList!=null && CustomerList.size()>0)
        {
            Database.update(CustomerList);
            system.debug('Records Updated'+CustomerList);
        }
     }
    global void finish(Database.BatchableContext BC)
    {
        Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
        AsyncApexjob a= [select a.Totaljobitems, a.Status,a.NumberOfErrors,a.JobType,a.JobItemsProcessed,a.ExtendedStatus,a.CreatedById,a.CompletedDate from AsyncApexJob a where id= :BC.getJobId()];
        system.debug('JobId'+BC.getJobId());
        mail.SetToAddresses(email);        
        mail.SetReplyTo('a.sakthidhn@gmail.com');
        mail.SetSenderDisplayName('Apex Batch Processing Module');
        mail.setSubject('Batch Status' +a.Status);
        mail.setPlainTextBody('The Batch Apex Job Processed'+a.TotalJobItems+'Batches with'+a.NumberOfErrors+'Failures'+'Job Proceesed are'+a.JobItemsProcessed);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
     }
}
//Requirement : we need to create a Contact record every time when you create a new Account
*************
trigger AccountTrigger on Account (after insert) {
List<Contact> ContactList=new List<Contact>();
for(Account a: Trigger.new)
    {
    Contact C=new Contact();
    C.LastName=a.Name;
    ContactList.Add(C);
    }
    insert ContactList;
}
***************************
//Facing the below error when i try to create a new Account
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger AccountTrigger caused an unexpected exception, contact your administrator: 
AccountTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. 
First exception on row 0; first error: 
FIELD_CUSTOM_VALIDATION_EXCEPTION, u cant insert anew record without email: []: Trigger.AccountTrigger: line 9, column 1
@isTest
global class CQP_ClsTriggerOpportunityHttpResGen implements HttpCalloutMock{

    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {      
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
		res.setBody('{"TYPE":"type","SAPID":"1234"","NUMBER":"100","MESSAGE":"message","LOG_NO":"log_no","LOG_MSG_NO":"100","MESSAGE_V1":"msg1","MESSAGE_V2":"msg2","MESSAGE_V3":"msg3","MESSAGE_V4":"msg4","PARAMETER":"param","ROW":"row","FIELD":"field","SYSTEM":"system"}');
        res.setStatusCode(200);
        res.setStatus('OK');
        return res;
    }
}

***************main class ****************
List<Object> results = (List<Object>) JSON.deserializeUntyped(res.getBody());
for (Object mp: results) {
System.debug('>>'+(Map<String, Object>)mp); 
Map<String, object> jsonRespMap = (Map<String, Object>)mp;
Boolean result = Boolean.valueof(jsonRespMap.get('success'));
if(result == true){
afterUpdateSuccess(opty1);
}

Error details:
Error MessageSystem.JSONException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries at [line:1, column:31]
Stack TraceClass.System.JSON.deserializeUntyped: line 11, column 1
Hi all ,
getting the below eeror while excuting batch
Line: 2, Column: 10
Method does not exist or incorrect signature: void executeBatch(CustomerProcessingBatch) from the type Database

Executing the below code in Anonymous window 

CustomerProcessingBatch objectClass=new CustomerProcessingBatch();
Database.executeBatch(objectClass);

ApexClass:
global class CustomerProcessingBatch implements Database.Batchable<sObject>
{
    global String[] email=new string[] {'a.sakthidhn@gmail.com'};
    //start method
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
       return Database.getQueryLocator('select id,name,Customer_Status__c,Customer_Description__c from Apex_Customer__c where Active__c=true');
    }
    //execute
    global void execute(Database.BatchableContext BC,List <sObject> scope)
    {
        List<Apex_Customer__c> CustomerList=new List<Apex_Customer__c>();
        for(sObject objscope: scope)
        {
            Apex_Customer__c newobjscope=(Apex_Customer__c)objscope;
            newobjscope.Customer_Description__c='Records updated via Batch Job';
            newobjscope.Customer_Status__c='Paid';
            CustomerList.Add(newobjscope);
            system.debug('Records Updated' +CustomerList);
        }
        if(CustomerList!=null && CustomerList.size()>0)
        {
            Database.update(CustomerList);
            system.debug('Records Updated'+CustomerList);
        }
     }
    global void finish(Database.BatchableContext BC)
    {
        Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
        AsyncApexjob a= [select a.Totaljobitems, a.Status,a.NumberOfErrors,a.JobType,a.JobItemsProcessed,a.ExtendedStatus,a.CreatedById,a.CompletedDate from AsyncApexJob a where id= :BC.getJobId()];
        system.debug('JobId'+BC.getJobId());
        mail.SetToAddresses(email);        
        mail.SetReplyTo('a.sakthidhn@gmail.com');
        mail.SetSenderDisplayName('Apex Batch Processing Module');
        mail.setSubject('Batch Status' +a.Status);
        mail.setPlainTextBody('The Batch Apex Job Processed'+a.TotalJobItems+'Batches with'+a.NumberOfErrors+'Failures'+'Job Proceesed are'+a.JobItemsProcessed);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
     }
}
I am new to lightning . I am getting the below error

"This page has an error. You might just need to refresh it.
Error in $A.getCallback() [Component is not defined]
Callback failed: apex://getAccountList/ACTION$getAllAccounts
Failing descriptor: {c:AccList}"

My Code:
****************Apex class****************
public class getAccountList {
    @AuraEnabled
    public static List<Account> getAllAccounts(){
        return[select Id,Name,Type,Phone from Account ];
    }
     @AuraEnabled
    public static List<Account> getFilterAccounts(){
        return[select Id,Name,Type,Phone from Account where Type='Prospect'];
    }
}
************COMPONENT************************
<aura:component controller="getAccountList" >
    <aura:attribute name="AccList" type="List" />
    <aura:attribute name="PaginationList" type="Account[]" />
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:attribute name="Pagesize" type="Integer" default="10" />
    <aura:attribute name="Totalsize" type="Integer" />
    <tr><ui:inputSelect aura:id="records" >
        <ui:inputSelectOption text="10" value="10"/>
        <ui:inputSelectOption text="20" value="20"/>
        <ui:inputSelectOption text="30" value="30"/>
    </ui:inputSelect></tr>
    <table>
        <thead>
            <th>Id</th>
            <th>Name</th>
            <th>Phone</th>
            <th>Type</th>
        </thead>
     <tbody>
            <aura:iteration items="{! v.AccList}" var="Acc" >
                <tr>
                    <td>{! Acc.Id}</td>
                    <td>{! Acc.Name}</td>
                    <td>{! Acc.Phone}</td>
                    <td>{! Acc.Type}</td>
                    <td><c:Menu testRecord="{! Acc.Id}"/></td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>
********************Controller*******************
({
    doInit : function(component, event, helper){
        helper.callServerMethod(component,"c.getAllAccounts","v.AccList");    
       
    }

})
*******************Helper*****************************
({
    callServerMethod : function(component,methodName,attributeName) {
    var Pagesize = component.get("v.Pagesize");
    var methodRef = component.get(methodName);
        methodRef.setCallback(this,function(response){
            if(response.getState()=="SUCCESS"){
                component.set(attributeName,response.getReturnValue());
            }else{
                alert("Problem in method call");
            }
            Component.set("v.Totalsize",component.get(methodName).length);
            var PaginationList = [];
            for(var i=0;i<Pagesize;i++)
            {
                PaginationList.push(response.getReturnValue()[i]);
            }
            component.set("v.PaginationList",PaginationList);
        });
        $A.enqueueAction(methodRef);
    }    
})
Scenario: To count the the total cases in the account whenever creating a new case and up[date the case count field in account object through trigger and class
Issue: Case Count field is not updated in account record when the new case getting created 

trigger newCaseInsert on Case (after insert) {
    for(Case cs: trigger.new)
    getCaseCount.getupdatedCount(cs.Account.id);
    }

public class getCaseCount {
     public static Integer CountValue;
     public static Integer getupdatedCount(String AccountId){
         CountValue =[Select COUNT() from Case where Account.id=:AccountId];
         List<Account> record= [Select id,Name,Case_Count__c from Account where Account.id=:AccountId];
         for(Account acts: record){
           acts.Case_Count__c=CountValue;
         }
         update record;
         return CountValue ; 
    }  
}
Error:Apex trigger Test caused an unexpected exception, contact your administrator: Test: execution of AfterUpdate caused by: System.StringException: Invalid id: Dickenson Mobile Generators: Trigger.Test: line 8, column 1
Scenario: whenever the stage field changed to Close won in opportunities , a new object record (Litrack__c)should be created.
Code:
trigger Test on Opportunity (after update) {
    Map<Id,Litrack__c> LitInsert= new Map<Id,Litrack__c>();
    for(Opportunity opNew: Trigger.new){
        for(Opportunity opOld: Trigger.old){
            if(opNew.StageName!=opOld.StageName && opNew.StageName=='Closed Won'){
                Litrack__c Record = new Litrack__c();
                Record.Name=opNew.id;
                Record.Opportunity_Lookup__c=opNew.Name;
                LitInsert.put(Record.id,Record);
            }
        }
      
                insert LitInsert.values();
             
}
}
For example i want to count the records in opportunity for the conditions like type='New customer' and StageName='Prospecting' in a single query?
plz reply back with your answers, thanks in Advance
Hi all,

Error: This page has an error. You might just need to refresh it.
Error in $A.getCallback() [response.getReturnValue is not a function]
Callback failed: apex://getAccountList/ACTION$getFilterAccounts
Failing descriptor: {c:AccList}

**************component
<aura:component controller="getAccountList">
    <aura:attribute name="AccList" type="List" />
    <lightning:button label="Get All Filter Accounts" onclick="{! c.getFilterAccountss}" />
    <aura:iteration items="{! v.AccList}" var="Acc" >
        <tr>
            <td>{! Acc.Id}</td>
            <td>{! Acc.Name}</td>
            <td>{! Acc.Phone}</td>
            <td>{! Acc.Type}</td>
        </tr>
    </aura:iteration>
</aura:component>
********************apex class
public class getAccountList {
   
     @AuraEnabled
    public static List<Account> getFilterAccounts(){
        return[select Id,Name,Type,Phone from Account where Type='Prospect'];
    }

}
************************controller
({
    getFilterAccountss : function(component, event, helper) {
        var accRef = component.get("c.getFilterAccounts");
        accRef.setCallback(this,function (response){
           var response = response.getState(); 
            if(response=="SUCCESS"){
                //alert("Success");
                  component.set("v.AccList",response.getReturnValue());
            }else{alert("No Response")}
        });
        $A.enqueueAction(accRef);
    }
   
})

please help me to resolve this issue
Apex Class
/*
Having the Utilities of the Askiiris Integration
*/
public without Sharing class Integration_Util {
    Public Static FINAL String DML_ERROR='Error Occured While Saving Record To database';
    /*
Method to log the integration trace in notes
*/
    Public Static void InsertNote(id parentId,string body,string title,boolean isPrivate,boolean ExceptionOccured){
        note resp = new note();
        resp.parentId = parentId; 
        resp.body =body; 
        resp.title = title; 
        resp.isPrivate = isPrivate; 
        database.insert(resp,false); 
    }
     /*
Method to send the Exception Email to CMSO-PS
*/
    public static void sendExceptionEmail(String[] emailId,String subject,String emailBody){
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setToAddresses(emailId); 
        semail.setSubject(subject); 
        semail.setHtmlBody(emailBody); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}); 
    } 
    /*
Method to get the Integration Credentials
*/
    Public Static CredentialsWrapper getCredetials( String credentialDevName){
        Integration_Credentials_Mapping__mdt mdt=[select id,Production_End_point_URI__c,Sanbox_End_point_URI__c,
                                                  Sandbox_password__c,Sandbox_user_name__c,Production_password__c,
                                                  Production_user_name__c,security_hns__c,Suffix_URL_1__c,Suffix_URL_2__c,
                                                  Sandbox_Auth_URI__c,Production_Auth_URI__c
                                                  From Integration_Credentials_Mapping__mdt 
                                                  where DeveloperName=:credentialDevName LIMIT 100];
        
        boolean isSandbox=[SELECT issandbox from organization LIMIT 1].isSandbox;
        CredentialsWrapper credwrap=new CredentialsWrapper();
        if(isSandbox){
            credwrap.enpointUrl=mdt.Sanbox_End_point_URI__c;
            credwrap.username =mdt.Sandbox_user_name__c;
            credwrap.password =mdt.Sandbox_password__c;
            credwrap.authTokenUrl =mdt.Sandbox_Auth_URI__c; 
        }else{
            credwrap.enpointUrl=mdt.Production_End_point_URI__c;
            credwrap.username=mdt.Production_user_name__c;
            credwrap.password=mdt.Production_password__c;
            credwrap.authTokenUrl =mdt.Production_Auth_URI__c; 
        }
        credwrap.hnsUrl=mdt.security_hns__c;
        credwrap.isSandbox=isSandbox;
        credwrap.suffixUrl1=mdt.Suffix_URL_1__c;
        credwrap.suffixUrl2=mdt.Suffix_URL_2__c;
        
        return credwrap;
    } 
    /*
Wrapper class used wrap the Integration Credentials
*/
    Public without sharing class CredentialsWrapper{
        Public String username;
        Public String password;
        Public String enpointUrl;
        Public String hnsUrl;
        public Boolean isSandbox;
        Public String suffixUrl1;
        public String suffixUrl2;
        Public String authTokenUrl;
        
    }
    
}

My Test Class

@isTest
public class Integration_Util_UT {

    private static testmethod void InsertNote() {
    Integration_Util.InsertNote('00300000003T2PGAA0','hello','hello',True,True);
     }                    
                    
    private static testmethod void sendExceptionEmail() {
        Integration_Util.sendExceptionEmail('fdgd@df.com','hello','hello');
       }                
                    
    private static testmethod void getCredetials() {
        Integration_Util.getCredetials('hello');
        }                    
}                

My error : "Method does not exist or incorrect signature: void sendExceptionEmail(String, String, String) from the type Integration_Util"
Also the current code coverage is 31%, please hep me to get code coverage 
Thanks in advance
Hi all ,
getting the below eeror while excuting batch
Line: 2, Column: 10
Method does not exist or incorrect signature: void executeBatch(CustomerProcessingBatch) from the type Database

Executing the below code in Anonymous window 

CustomerProcessingBatch objectClass=new CustomerProcessingBatch();
Database.executeBatch(objectClass);

ApexClass:
global class CustomerProcessingBatch implements Database.Batchable<sObject>
{
    global String[] email=new string[] {'a.sakthidhn@gmail.com'};
    //start method
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
       return Database.getQueryLocator('select id,name,Customer_Status__c,Customer_Description__c from Apex_Customer__c where Active__c=true');
    }
    //execute
    global void execute(Database.BatchableContext BC,List <sObject> scope)
    {
        List<Apex_Customer__c> CustomerList=new List<Apex_Customer__c>();
        for(sObject objscope: scope)
        {
            Apex_Customer__c newobjscope=(Apex_Customer__c)objscope;
            newobjscope.Customer_Description__c='Records updated via Batch Job';
            newobjscope.Customer_Status__c='Paid';
            CustomerList.Add(newobjscope);
            system.debug('Records Updated' +CustomerList);
        }
        if(CustomerList!=null && CustomerList.size()>0)
        {
            Database.update(CustomerList);
            system.debug('Records Updated'+CustomerList);
        }
     }
    global void finish(Database.BatchableContext BC)
    {
        Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
        AsyncApexjob a= [select a.Totaljobitems, a.Status,a.NumberOfErrors,a.JobType,a.JobItemsProcessed,a.ExtendedStatus,a.CreatedById,a.CompletedDate from AsyncApexJob a where id= :BC.getJobId()];
        system.debug('JobId'+BC.getJobId());
        mail.SetToAddresses(email);        
        mail.SetReplyTo('a.sakthidhn@gmail.com');
        mail.SetSenderDisplayName('Apex Batch Processing Module');
        mail.setSubject('Batch Status' +a.Status);
        mail.setPlainTextBody('The Batch Apex Job Processed'+a.TotalJobItems+'Batches with'+a.NumberOfErrors+'Failures'+'Job Proceesed are'+a.JobItemsProcessed);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
     }
}
//Requirement : we need to create a Contact record every time when you create a new Account
*************
trigger AccountTrigger on Account (after insert) {
List<Contact> ContactList=new List<Contact>();
for(Account a: Trigger.new)
    {
    Contact C=new Contact();
    C.LastName=a.Name;
    ContactList.Add(C);
    }
    insert ContactList;
}
***************************
//Facing the below error when i try to create a new Account
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger AccountTrigger caused an unexpected exception, contact your administrator: 
AccountTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. 
First exception on row 0; first error: 
FIELD_CUSTOM_VALIDATION_EXCEPTION, u cant insert anew record without email: []: Trigger.AccountTrigger: line 9, column 1