• Sachin Hooda
  • NEWBIE
  • 340 Points
  • Member since 2020

  • Chatter
    Feed
  • 9
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 58
    Replies
I need display data as a list receiving via class FindDuplicateCase to aura component. But I have empty page, although the class returns values when debugging 
Class Apex
public class FindDuplicateCase {
@AuraEnabled
    public static List<Case> getCaseListDuplicate(){
        List<Case> caseFields =[SELECT Id,CaseNumber,Origin,Subject,SuppliedEmail,Status,Reason,OwnerId FROM Case WHERE Status!='Closed'];
        List<Case> duplicateCaseList = new List<Case>();
        for(Case case1:caseFields){
           for(Case case2:caseFields){
               if(case1.Subject==case2.Subject && case1.SuppliedEmail==case2.SuppliedEmail && case1.Reason==case2.Reason){
                    duplicateCaseList.add(case1);
               }
            }
        }
        return duplicateCaseList; 
    }
}
Aura component 
<aura:component implements="force:lightningQuickAction" controller="FindDuplicateCase" access="global">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    <aura:attribute name="duplicateCaseList" type="List" />
        <aura:iteration items="{!v.duplicateCaseList}" var="item">
                <ul>
                <li>Case Number{!item.CaseNumber}</li>
            </ul>
           </aura:iteration>     
</aura:component>
Javascript 
({
    doInit: function(component, event, helper) {
        const list = component.get('c.getCaseListDuplicate');
        component.set("v.duplicateCaseList",list);
        $A.enqueueAction(list);
    }
})
calci.js file is:

import { LightningElement  ,track} from 'lwc';
export default class Calculator extends LightningElement {}
-----------------------------------------------------------------------------------------
calci.html file is 
<template>
<ligtning-card title="Calci" icon-name="standard:formula">
<ligtning-layout multiple-rows>
<lightning-layout-item size="12"  padding="around-medium">
<lightning-input type="number" name="FirstNumber"></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-input type="number" name="SecondNumber"> </lightning-input>
        </lightning-layout-item>
        <lightning-layout-item size="12" padding="around-medium"> 
<lightning-button-group>
<lightning-button label="Add" icon-name="utility:add" icon:position="right"></lightning-button> 
<lightning-button label="Subtract" icon-name="utlity:dash"  icon:position="right"></lightning-button>
<lightning-button label="Multiply" icon-name="utlity:close" icon:position="right"></lightning-button>
<lightning-button label="Divide" icon-name="utlity:magicwand" icon:position="right"></lightning-button>
</lightning-button-group>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-formated-text value={}></lightning-formated-text>
</lightning-layout-item>
</ligtning-layout>
</ligtning-card>
</template>
--------------------------------------------------------------------------
calci.js-meta.xml file is 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="calci">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <description> Simple calculator app build with LWC</description>
    <targets>
    <target> lightning__AppPage  </target>
    <target> lightning__HomePage</target>
    <target> lightning_RecordPage</target>
    </targets>
</LightningComponentBundle>
public class AccountSelectContact{
    public List<WrapAccount> wrapAccList{get;set;}
    public List<Account> selectedAccounts{get;set;}
    public List<Contact> conList{get;set;}
    public AccountSelectContact(){
        if(wrapAccList== null){
            wrapAccList= new List<WrapAccount>();
          List<Account> accList=[select id, name,(select id,name,phone from contacts) from Account];
            for(Account a: accList){
                wrapAccList.add(new WrapAccount(a));
            }
        }
        system.debug('wrapAccList++'+wrapAccList);
    }
    public void processSelected(){
        wrapAccList= new List<WrapAccount>();
        selectedAccounts= new List<Account>();
        conList=[select id,name,phone from Contact where id IN: accList];
        for(WrapAccount w:conList){
            if (w.selected==true){
              selectedAccounts.add(w.conList);
            }
        }
    }
    public class WrapAccount{
        public Account acc{get;set;}
        public Boolean selected{get;set;}
        public WrapAccount(Account a){
            this.acc=a;
            this.selected=false;
        }
    }
}
Hello, I am trying to write a test class for the following VF Page
I wrote a test class but I am getting 0% code coverage for the controller I am trying to test...
VF Page:
<apex:page Controller="ResourceListController" renderAs="PDF" >
    <apex:form >
            <apex:image id="AdobeLogo" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009UPQ'}" width="100%" height="125"/>
        <br></br>
    <br></br>
<br></br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        <br></br>
    <br></br>
<br></br> 
Please contact Adobe Care and Wellness at 4807205699 for any questions regarding your Resource List.
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<div style="text-align:center">
            <apex:image id="ArizonaLandScape" value="{!'/servlet/servlet.FileDownload?file= 0152f0000009Uhy'}" width="75%" height="75%"/>
           </div>

<div style="page-break-after:always;">
</div>
<br></br>
<br></br>
<br></br>

    <apex:repeat var="RL" value="{!ResourceList}"> 
        <table border="1" style="width:100%" >
            <tr>
            <th >Name</th>
                </tr>
            <tr>
          <td>{!RL.Account__r.Name}</td>
                </tr>
                       <tr>
            <th>Description</th>
                </tr>
            <tr>
          <td>{!RL.Account__r.Description}</td>
                </tr>
           <tr>
            <th>Address</th>
           </tr>
            <tr>
          <td>{!RL.Account__r.BillingStreet}<br></br> 
            {!RL.Account__r.BillingCity}, {!RL.Account__r.BillingState} {!RL.Account__r.BillingPostalCode} </td>
                </tr>

            
        </table>
        <table border="1" style="Width:100%">
         <tr>
            <th>Phone</th><th>Type</th><th>Distance</th>
           </tr>
        
                    <tr>
          <td>{!RL.Account__r.Phone}</td><td>{!RL.Type__c}</td><td>{!RL.Distance__c} miles</td>
                </tr>
            </table>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>




     </Apex:Repeat>
                 
        </apex:form>
</apex:page>
Controller
public class ResourceListController {
   public Id RecordId {get;set;}    
public List<Resource_List__c> getResourceList() {
    RecordId  = ApexPages.currentPage().getParameters().get('id');
    List<Resource_List__c> results = Database.query(
        'SELECT Id, Account__c, Account__r.Name, Distance__c, type__c, Account__r.Phone, Account__r.Description, Account__r.billingStreet, Account__r.billingCity, Account__r.billingPostalCode, Account__r.billingState ' +
        'FROM Resource_List__c ' + 
        'Where Social_Services_Assessment__c = :RecordId' +
        'ORDER BY Type__c asc, Distance__c asc'
    );
    return results;
}
    
    
}
Test Class
@isTest
public class resourceListTestClass {
	static testMethod void testMethod1()
    {
        Account ta = new Account();
        ta.name = 'Alex Demo';
        ta.First_Name__c = 'Alex';
        ta.Surname__c = 'Demo';
        ta.Primary_Insurance__c = 'Test Insurance Company';
        ta.Gender__c ='Male';
        ta.County__c ='Yavapai';
        ta.BillingStreet = '123 West Gurley Street';
        ta.BillingCity = 'Prescott';
        ta.BillingState = 'Arizona';
        ta.BillingPostalCode = '86303';
        ta.RecordTypeId = '012360000004FEPAA2';
        insert ta;
        
        Social_Services_Assesment__c sw = new Social_Services_Assesment__c ();
        sw.Account__c = ta.Id;
        sw.Radius_in_miles__c = 25;
        sw.Monthly_income__c = 5000;
        sw.Do_you_have_enough_money_each_month__c = 'No';
        sw.Do_you_recieve_SSI__c = 'No';
        sw.Do_you_receive_SSDI__c = 'No';
        sw.Do_you_receive_food_assistance__c = 'No';
        sw.Do_you_receive_cash_assistance__c = 'No';
        sw.Do_you_have_adequate_shelter__c = 'No';
        sw.Do_you_need_congregate_meals__c = 'Yes';
        sw.Do_you_need_transportation__c = 'Yes';
        sw.Do_you_have_enough_money_each_month__c = 'No';
        sw.Can_you_pay_for_your_housing__c = 'No';
        sw.Can_you_pay_your_utilities__c = 'No';
        sw.Can_you_pay_for_transportation__c = 'No';
        sw.Can_you_pay_for_medical_visits__c = 'No';
        sw.Are_you_unemployed__c = 'Yes';
        sw.SSI_SSDI_decreased__c = 'Yes';
        sw.RecordTypeId = '0121R000000yZUyQAM';
        insert sw;
        
        Account r1 = new Account ();
        r1.RecordTypeId = '0121R000000yZGLQA2';
        r1.Name = 'Resource 1';
        r1.Food_Bank__c = true;
        r1.Financial_Assistance__c = true;
        insert r1;
        
        Account r2 = new Account ();
        r2.RecordTypeId = '0121R000000yZGLQA2';
        r2.Name = 'Resource 2';
        r2.Food_Bank__c = true;
        r2.Financial_Assistance__c = true;
        insert r2;
        
        Resource_List__c RL1 = new Resource_List__c ();
        RL1.Account__c = r1.Id;
        RL1.Social_Services_Assessment__c = sw.id;
        insert RL1;
        
        Resource_List__c RL2 = new Resource_List__c ();
        RL2.Account__c = r2.Id;
        RL2.Social_Services_Assessment__c = sw.id;
        insert RL2;
        
        Test.StartTest();
		PageReference PageRef = Page.ResourceList;
        Test.setCurrentpage(PageRef);
        System.currentPageReference().getParameters().put('RecordId',sw.Id);
        ResourceListController controller = new ResourceListController();
		Test.StopTest();
        
    }
}

 
Hello LWC gurus: please help.
I'm calling out a REST service that returns a JSON response that contains a Parent-Child relationship.  For example, response contains 10 Sales Orders, each Sales Order can upto 100+ Order lines.   I want to show the Orders in LWC as HTML table, and when the user clicks on one particular Order (row action?!), all the Order Lines of that Order should be displayed.  What is the best approach from LWC perspective? If you can point to some example code that would be of great help. Thank you.
Hi All,

I have created a rest api webservice to insert contentVersion into salesforce but now I want to return the list of files to external system using rest api webservice. And I don't want to send exact files associated with case instead I want to send url so, external user can easily access  files from this url (list of url).
Any help how to proceed?
And any sample code really appreciate...


Best Regards,
Rahul 
Hi all ,
     I had also faced the similar issue  (Unable to find action 'createAccount' on the controller of c:Event11comp ).    please go through the code below 
Event :
         <aura:event type="APPLICATION" description="Event template" >
         <aura:attribute name="acc" type="Account"/>
        </aura:event>

component 1 :
  <aura:component >
    <aura:registerEvent name="first" type="c:Event11"/>
    <aura:attribute name="acc" type="Account" default="{'sobjectType':'Account'}" />
    <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
        <lightning:card title="" iconName="standard:account">
            <aura:set attribute="title">
                <h1>New customer</h1>
            
            </aura:set>
            <aura:set attribute="actions">
                <lightning:button label="save" onclick="{!c.doSave}"/>
                <lightning:button label="cancel" onclick="{!c.doCcancel}"/>
             </aura:set>
                 <div style="padding:20px;">
                     <lightning:input label="Name"     value="{!v.acc.Name}"/>
                     <lightning:input label="Phone"    value="{!v.acc.Phone}"/>
                     <lightning:input label="Industry" value="{!v.acc.Industry}"/>                  
                </div>
    
    
    
    
        </lightning:card>
    </div>
    
</aura:component>

component 1 controller :
              ({
    doSave : function(component, event, helper) {
        var accRecord = component.get("v.acc");
        var action = component.get("c.createAccount");
        action.setParams({"objA":accRecord});
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state == 'SUCCESS'){
                var res = response.getReturnValue();
                if(res !='Error'){
                var evt = $A.get("e.c:Event11");
                evt.setParams({"acc":accRecord});   
                evt.fire();
            }
            }
        });
        
        
        
        
        
        
        
        $A.enqueueAction(action);
        
    },
    doCancel : function(component, event, helper) {
        component.set("v.acc",null);
    }
})


component 2 :
       <aura:component controller="controllerDml">
    <aura:attribute name="accountdata" type="Account" default="{'sobjectType':'Account'}"/>
    <aura:attribute name="flag" type="boolean"  default="flase"/>
    <aura:handler name="Submit" event="c:Event11" action="{!c.doSubmit}"/>
   
    <aura:if isTrue="{!v.flag}">
     <div style="margin-left:100px;margin-top:100px;width:500px;border:1px solid green;">
       <lightning:card title="customer Details" iconName="standard:account">
           <div style="padding:20px;"> 
            <b>Name</b>     :  {!v.accountdata.Name}<br/>
            <b>Phone</b>    :  {!v.accountdata.Phone}<br/>
            <b>Industry</b> :  {!v.accountdata.Industry}
           </div>
       </lightning:card>
     </div>
    
    
    </aura:if>
    
</aura:component>
component 2 controller:

({
    doSubmit : function(component, event, helper) {
        var acc1 = event.getParam("acc");
        component.set("v.accountdata",acc1);
        component.set("v.flag",true);
        
    }
})

Application:
 <aura:application extends="force:slds" >
    <c:Event11comp />
    <c:Event11comp1 />
    
</aura:application>

Apex class:

 public class controllerDml {
    @auraEnabled
    public static string createAccount(Account objA) {
         try{
             Insert objA;
             return objA.Id;
            }
          catch(Exception e) {
              return 'Error';
               }
    }

}
 
public class params1 {
    @AuraEnabled
    public static List<Opportunity> ops(String oStagename,String oType){
        List<Opportunity> opportunities=[select Id,Name,Stagename,Type from Opportunity where StageName=:oStagename and Type=:oType limit 4];
        return opportunities;
    }
}


<aura:component controller="params1">
    <aura:attribute name="optylist" type="List"/>
    <lightning:input label="StageName" aura:id="sname" />
    <lightning:input label="CustomerType" aura:id="cust"/>
    <lightning:button label="Submit" onclick="{!c.invoke}"/>
    
    <aura:iteration items="{!v.optylist}" var="a">
    	<p>{!a.Name} &nbsp;&nbsp;&nbsp;{!a.Stagename}&nbsp;&nbsp;&nbsp;{!a.Type}</p>
    </aura:iteration>
</aura:component>


({
    invoke : function(component, event, helper) {
        var stagename=component.find("sname").get("v.value");
        var type=Component.find("cust").get("v.value");
        
        var action=component.get("c.ops");
        action.setParams({"oStagename":stagename,"oType":type});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state==='SUCCESS'){
                console.log('Operation successful');
                component.set("v.optylist",response.getReturnValue());
            }
        })
        $A.enqueueAction(action);
    }
       
})


<aura:application extends="force:slds">
	<c:parasm />
</aura:application>

 
Hello Developers

I want to design a batch apex where it should fire an email on daily basis, and i have designed a visualforce component and controller with vf email templates where it sends reports with csv attachments, How do i design a batch apex class where it can send the vf email templates on daily basis

This is my VF component
 
<apex:component controller="ReportsToEmailController" access="global">
    <apex:attribute name="ReportId" description="Report ID" type="Id" assignTo="{!rptId}"/>
    <apex:attribute name="Color" description="Background color" type="String" assignTo="{!rptId}"/>
    <apex:outputPanel >      
        
        <table style="width: 100%;">
            <thead style="background : {!Color}">                
                <apex:repeat value="{!ReportResult.reportMetadata.detailColumns}" var="colName">
                    
                    <!-- reportMetadata is a class where it contains metadata of a report.
DetailColumns is a method of ReportMetadata class, it returns the API names(Coloumns Names)
for the fields that contain detailed data-->
                    
                    <th><apex:outputText value="{!ReportResult.reportExtendedMetadata.detailColumnInfo[colName].label}"/></th>
                    
                    
                    <!-- reportExtendedMetadata is class where it contains Report extended metadata and
it provides data type and label information.
detailColumnInfo is a method of reportExtendedMetadata clas, it returns map of columns names
and its label to Display as Header -->
                    
                </apex:repeat>
                <!-- Grouped fieds in summary report to get in header -->
                <apex:repeat value="{!ReportResult.reportMetadata.groupingsDown}" var="colName">
                    <th><apex:outputText value="{!colName.name}"/></th>
                </apex:repeat>
            </thead>
            <tbody>
                
                <!-- Summary Report with 2 level of grouping -->
                <apex:repeat value="{!ReportResult.groupingsDown.groupings}" var="groupingLevel1" >
                    <apex:repeat value="{!groupingLevel1.groupings}" var="groupingLevel2" >
                        <apex:repeat value="{!ReportResult.factMap[groupingLevel2.key+'!T'].rows}" var="row" rows="999">
                            <!-- Here we will get entire data of each row and T refers to the Row -->
                            <tr> <apex:repeat value="{!row.dataCells}" var="cell">
                                <!-- Here we will get data of each cell and displayed -->
                                <td><apex:outputText value="{!cell.label}"/></td>
                                </apex:repeat><td>{!groupingLevel1.label}</td><td>{!groupingLevel2.label}</td> </tr>
                        </apex:repeat>
                    </apex:repeat>
                </apex:repeat>
                
                <!-- Summary Report with 1 level of grouping -->
                <apex:repeat value="{!ReportResult.groupingsDown.groupings}" var="grouping" >
                    <apex:repeat value="{!ReportResult.factMap[grouping.key+'!T'].rows}" var="row" rows="999">
                        <!-- Here we will get entire data of each row and T refers to the Row -->
                        <tr> <apex:repeat value="{!row.dataCells}" var="cell">
                            <!-- Here we will get data of each cell and displayed -->
                            <td><apex:outputText value="{!cell.label}"/></td>
                            </apex:repeat><td>{!grouping.label}</td> </tr>
                    </apex:repeat>
                </apex:repeat>
                
                <!-- Tabular Report -->
                <apex:repeat value="{!ReportResult.factMap['T!T'].rows}" var="row" rows="999">
                    <!-- Here we will get entire data of each row and T refers to the Row -->
                    <tr> <apex:repeat value="{!row.dataCells}" var="cell">
                        <!-- Here we will get data of each cell and displayed -->
                        <td><apex:outputText value="{!cell.label}"/></td>
                        </apex:repeat></tr>
                </apex:repeat>
                <!--</apex:repeat>-->
            </tbody>
        </table>
    </apex:outputPanel>
</apex:component>

apex controller
 
public class ReportsToEmailController {
    public Id rptId { get; set; } // Here we will get the report Id from the VF Component
    private transient Reports.ReportResults results; // It will hold the entire data of a report
 
    /*********************
     // Method Name : getReportResult
     // Description : Here we will get the data of a report and send to the VF Component
    /********************/
 
    public Reports.ReportResults getReportResult() {
        // Here it will run the report with that report ID and adding the report data into results
        results = Reports.ReportManager.runReport(rptId, true);
        return results;
    }
}

Vf template
 
<messaging:emailTemplate subject="Report" recipientType="User" >
    <messaging:plainTextEmailBody >
        Hi {!recipient.FirstName}
        Please find the below attachments. 
 
    </messaging:plainTextEmailBody>
    <messaging:attachment filename="Account Report.xls">
        <!-- Here we can add multiple Reports -->
        <c:ReportsToEmail ReportId="00O2w000002RDbUEAW"/>
        <c:ReportsToEmail ReportId="00O2w000002Rp56EAC"/>
    </messaging:attachment>
</messaging:emailTemplate>

Can someone help me with the batch apex
Hi All,

After update trigger on the opportunity Object.

If the Title__c field on the Opportunity object have CEO as the title  then I should be able to update countofCEO field on the Account object
So when a user update the title__ field from CEO to Blank then counter on the Account object should decrease by 1 and vice versa

When I Update from CEO to Blank ,code run's fine but when I update same record and change Title field from blank to CEO then I get  null pointer Exception and am not sure how to remove it.

Exception as per Salesforce.

CountOfOppwithCEOTitle: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.CountOfOppwithCEOTitle: line 77, column 1


Below given line is the culprit.

As per the debug logs ,Below given line is an issue
if(Trigger.oldmap.get(opp.id).title__c.contains('CEO')


      if(Trigger.oldmap.get(opp.id).title__c.contains('CEO')&& opp.title__c==null)



if(trigger.isUpdate&& trigger.IsAfter)
  {
   Set<id>Accids=new set<id>();
   Map<id,opportunity>mapofOppIdtoOppRecords=new map<id,opportunity>();
   for(opportunity opp:trigger.new)
   {
       
       if(Trigger.oldmap.get(opp.id).title__c.contains('CEO')&& opp.title__c==null)
              
       //if(trigger.newmap.get(opp.id).title__c!=trigger.oldmap.get(opp.Id).title__c && (Trigger.oldmap.get(opp.id).title__c.contains('CEO')&& opp.title__c==null))
       {
                 
           system.debug('I am in the initial for loop');
           mapofOppIdtoOppRecords.put(opp.id,opp);
           Accids.add(opp.accountid);
                  
    }
       else
         if(opp.title__c!=trigger.oldmap.get(opp.Id).title__c && (String.isBlank(Trigger.oldmap.get(opp.id).title__c)&& opp.title__c.contains('CEO')))
               {
     
                
            mapofOppIdtoOppRecords.put(opp.id,opp);
            Accids.add(opp.accountid);
            
                
                
                
               }
   
   }

Map<id,Account>MapofAccountIdToAccount=new map<id,account>([select id,countofCEO__c from account where id in:Accids]);    
List<opportunity>Opp=[Select id,title__c,Accountid from Opportunity where id in:mapofOppIdtoOppRecords.keyset()];
list<account>acclist=new list<account>();  
for(Opportunity Opprecords:opp)
{
  system.debug('I am in for loop');
if(MapofAccountIdToAccount.containskey(opprecords.accountid)&& Opprecords.title__c==null)
  {
      
        system.debug('The debug value is');
   
        Account Acc=MapofAccountIdToAccount.get(Opprecords.Accountid);
        Acc.countofCEO__c=acc.countofCEO__c-1;
        acclist.add(acc);
      
      
 }
else
   
  if(MapofAccountIdToAccount.containskey(opprecords.accountid)&& Opprecords.title__c.contains('CEO'))
        {
        Account Acc=MapofAccountIdToAccount.get(Opprecords.Accountid);
        Acc.countofCEO__c=acc.countofCEO__c+1;
        acclist.add(acc);
      
            
            
            
        }
        
}
    try
    {
        
        if(!acclist.isEmpty()&& acclist.size()>0)
        {
            
            Map<id,Account>MapofAccountIdToOpp=new map<id,account>();
            MapofAccountIdToOpp.putall(acclist);
            update MapofAccountIdToOpp.values();
        }
    }
    catch(DmlException de)
    {
        
    }
    
    
}



Thanks




 
Aura Component:-

<aura:component controller="createAccount" implements="force:hasRecordId,flexipage:availableForRecordHome" >
    <aura:attribute name="createAccount" type="Account[]" default="{
                                                                   
                                                          'sObjectType' : 'Account',
                                                          'FirstName'   : ' ' ,
                                                          'LastName'    : ' ',
                                                          'BillingAddress' : ' ',
                                                          'Rating' : ' '        
                    
                                                                        }" />
  <aura:attribute name="starRating" type="List" default="[
    {'label': 'Hot', 'value': 'Hot'},
    {'label': 'Warm', 'value': 'Warm'},
    {'label': 'Cold', 'value': 'Cold'},
    ]"/> 
    
    <lightning:input aura:id="input1" label="FirstName" value="{!v.createAccount.FirstName}" required="True"/>
    <lightning:input aura:id="input2" label="LastName" value="{!v.createAccount.LastName}" required="True"/>
    <lightning:input aura:id="input3" label="Address" value="{!v.createAccount.BillingAddress}" required="True"/>
     <lightning:combobox name="sRating" label="Rating" value="None" placeholder="Select Progress" options="{!v.starRating }" 
                                                            onchange="{!c.handleChange }"/> 

     <lightning:button title="Neutral action" 
                                  label="Save"   
                                  onclick="{!c.handleClick}"/>
    
    </aura:component>

JS Controller:-
({
    handleChange : function(component, event, helper) {
        
        let selectedOptionValue = event.getParam("value"); 
        component.set("v.createAccount.Rating",selectedOptionValue);
        let values= component.get("v.createAccount.Rating");
        alert(values); 
        console.log(values);
    },
    
    handleClick : function(component, event, helper) {
        var target = event.getSource();
        var id = target.get("v.label");     
        alert(id);
        
         var action = component.get("c.createAcc");
        action.setParams({ 
         Acc : component.get("v.createAccount") });
 
        // Create a callback that is executed after 
        // the server-side action returns
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                alert('Record added');// Alert the user with the value returned 
                // from the server
                alert("From server: " + response.getReturnValue());
                 console.log('Sucessfully added content to Object');
                // You would typically fire a event here to trigger 
                // client-side notification that the server-side 
                // action is complete
            }
            else if (state === "INCOMPLETE") {
              alert("Incomplete");  // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
 
        // optionally set storable, abortable, background flag here
 
        // A client-side action could cause multiple events, 
        // which could trigger other events and 
        // other server-side action calls.
        // $A.enqueueAction adds the server-side action to the queue.
        $A.enqueueAction(action);
    

    
    }     
})

Apex Code:-

public class createAccount {
    
    @AuraEnabled
    public static Account createAcc(Account Acc){
                  
            insert Acc;
       
        return Acc;
    }
}
I need display data as a list receiving via class FindDuplicateCase to aura component. But I have empty page, although the class returns values when debugging 
Class Apex
public class FindDuplicateCase {
@AuraEnabled
    public static List<Case> getCaseListDuplicate(){
        List<Case> caseFields =[SELECT Id,CaseNumber,Origin,Subject,SuppliedEmail,Status,Reason,OwnerId FROM Case WHERE Status!='Closed'];
        List<Case> duplicateCaseList = new List<Case>();
        for(Case case1:caseFields){
           for(Case case2:caseFields){
               if(case1.Subject==case2.Subject && case1.SuppliedEmail==case2.SuppliedEmail && case1.Reason==case2.Reason){
                    duplicateCaseList.add(case1);
               }
            }
        }
        return duplicateCaseList; 
    }
}
Aura component 
<aura:component implements="force:lightningQuickAction" controller="FindDuplicateCase" access="global">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    <aura:attribute name="duplicateCaseList" type="List" />
        <aura:iteration items="{!v.duplicateCaseList}" var="item">
                <ul>
                <li>Case Number{!item.CaseNumber}</li>
            </ul>
           </aura:iteration>     
</aura:component>
Javascript 
({
    doInit: function(component, event, helper) {
        const list = component.get('c.getCaseListDuplicate');
        component.set("v.duplicateCaseList",list);
        $A.enqueueAction(list);
    }
})
Hello, i need to find records where a long text area field is not null. However i am getting an error that you cannot filter soql queries with long text areas. Is there any way to workaround this?

Hi all,

I am writing a Test Class for Apex REST Callout which is throwing an error as "Illegal assignment from void to System.HttpResponse" .

In the test class error is in this line

 HttpResponse response = Account6Class.postmethod(aId); 
 
Please help to reslove this error. Thanks in advance.

This is code of Trigger:
trigger Account6 on Account (after insert) {
        if (Trigger.isInsert) {
        Set<Id> accountIdSet = new Set<Id>();
        for(Account accObj: trigger.new){
            accountIdSet.add(accObj.id);
         }
        if(!accountIdSet.isEmpty()){
            Account6Class.postmethod(accountIdSet);
        }
    }

This is code of Class:
public class Account6Class {
@future(callout=true)
    public static void postmethod(Set<Id> accountIdset) {       
        string resultBodyGet = '';
        list<Account> accts = [SELECT  Name, Id, Description, Phone FROM Account WHERE Id IN:accountIdset];
       for(Account c : accts){         
            MAp<String, String> tags = new Map<String, String>();
            tags.put('id', c.Id);
            tags.put('Name', c.Name);
            tags.put('Description',c.Description);
            tags.put('Phone',c.Phone);               
            try{
                string endpoint = 'https://abc.com/xyz';
                HttpRequest req = new HttpRequest();
                req.setEndpoint(endpoint);
                req.setMethod('POST');
                req.setHeader('Content-type', 'application/json');
                req.setbody(JSON.serialize(tags));
                Http http = new Http();
                HTTPResponse response = http.send(req); 
                resultBodyGet = response.getBody();
                system.debug('Output response:' + resultBodyGet);
                accResponse myAccResponse = new accResponse();
                myAccResponse = (accResponse) JSON.deserialize(resultBodyGet, accResponse.class);
                system.debug('#### myAccResponse: ' + myAccResponse);
            }
            catch (exception e) {                              
            }   
        }
    }    
public class accResponse {
        public string message {get;set;}
    }
}

This is code of  HttpCallouMock Class:
@isTest
global class Account6Test implements HttpCalloutMock{
    global HTTPResponse respond(HTTPRequest request) {
         HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"Account": ["Test6"]}');
        response.setStatusCode(200);
        return response; 
    }
}

This is code of  Test Class:
@isTest
private class Account6Test1 {
    @isTest static void testPostCallout() {
        Test.setMock(HttpCalloutMock.class, new Account6Test() );
        Set<Id> aId = new Set<id>();
         Account test = new Account();
            test.Name = 'Test6';
            test.Description = 'FooDes';
            test.Phone = '1231231232';
            insert test;
            aId.add(test.Id);
          System.debug('Accounts are ' + aId);
        HttpResponse response = Account6Class.postmethod(aId);
        String contentType = response.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = response.getBody();
        System.debug(response.getBody());
        String expectedValue = '{"Account": ["Test6"]}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, response.getStatusCode());
        
    }
 }

User-added image
Trying to solve this badge:
https://trailhead.salesforce.com/en/content/learn/modules/api_basics/api_basics_soap

Resource URL:
https:/https://wise-panda-brtwcw-dev-ed.lightning.force.com/services/Soap/c/48.0/0DF5w0000008ZVP
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
   </soapenv:Header>
   <soapenv:Body>
      <urn:login>
         <urn:username>example1</urn:username>
         <urn:password>Example2</urn:password>
            </urn:login>
   </soapenv:Body>
</soapenv:Envelope>Request:
Error:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>sf:LOGIN_MUST_USE_SECURITY_TOKEN</faultcode>
         <faultstring>LOGIN_MUST_USE_SECURITY_TOKEN: Invalid username, password, security token; or user locked out. Are you at a new location? When accessing Salesforce--either via a desktop client or the API--from outside of your company’s trusted networks, you must add a security token to your password to log in. To get your new security token, log in to Salesforce. From your personal settings, enter Reset My Security Token in the Quick Find box, then select Reset My Security Token.</faultstring>
         <detail>
            <sf:LoginFault xsi:type="sf:LoginFault">
               <sf:exceptionCode>LOGIN_MUST_USE_SECURITY_TOKEN</sf:exceptionCode>
               <sf:exceptionMessage>Invalid username, password, security token; or user locked out. Are you at a new location? When accessing Salesforce--either via a desktop client or the API--from outside of your company’s trusted networks, you must add a security token to your password to log in. To get your new security token, log in to Salesforce. From your personal settings, enter Reset My Security Token in the Quick Find box, then select Reset My Security Token.</sf:exceptionMessage>
            </sf:LoginFault>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
 
Below code is not working can anyone help me in this...?

global class Date_Batch_Class implements Database.Batchable<sObject>{

        global Date_Batch_Class(){
                   // Batch Constructor
        }
       
        // Start Method
        global Database.QueryLocator start(Database.BatchableContext BC){
        
            string query = 'select id,LastName from Contact where OldDate__c = LAST_N_DAYS:5';
               System.debug('aaaaaaaaaaaaaaaaaaaaaaaa'+query) ; 
            return Database.getQueryLocator(query);

        }

      
      // Execute Logic
       global void execute(Database.BatchableContext BC, List<Contact>scope){
             
        delete scope;
     
       }
     
       global void finish(Database.BatchableContext BC){
            // Logic to be Executed at finish
       }
    }
Hi All,

I am having trouble with the below code:
 
Public Class SOQLTry{
    
    public static void showAccountsBasedOnRating(String AccountRating){
        
        List<Account> List2 = [SELECT Name, Rating
                               FROM Account
                               WHERE Rating IN (:AccountRating)];
            
        For(Account AAR : List2) {
            system.debug('Name of Account with Rating ' +AAR.Rating+' is '+AAR.Name );
        }
    }
    
    
    public static void showIndustryOfAccounts(String AccountIndustry){
        List<Account> List3 = [SELECT Name, Industry
                               FROM Account
                               WHERE Industry = :AccountIndustry];
        for(Account AAI : List3)
        	{
            IF(List3.isEmpty()==False)
            {
            system.debug(AAI.Name+' belongs to the '+AAI.Industry+' Industry');
            }
            
            ELSE 
            {
                system.debug('There is no account related to ');
            }
        }
    }
}

The showAccountsBasedOnRating() method is executing as per expectations.

The showIndustryOfAccounts() method is executing with upto "IF" command but the ELSE commoand is not executing.

Any idea what could be causing this.

Thanks.
 
Here I am planning to use the list value from one method to another, but i am getting null value, how can i get it, please suggest ASAP

public class RPC 
{
@AuraEnabled public  static List<Contact> contlist {get;set;} 
@AuraEnabled 
    public static  getContact(Id firstcontId){
        
       
       List <Contact> contlist=[select Id, AccountID, Name, LastName, FirstName, Ind_ID__c,  from Contact LIMIT 5];
    
    }
    
    

@AuraEnabled public static String  getRefreshInfo()
{
   system.debug(contlist);     ---//It gives me null value, how can i get the contlist from getContact and use it here
}


}
calci.js file is:

import { LightningElement  ,track} from 'lwc';
export default class Calculator extends LightningElement {}
-----------------------------------------------------------------------------------------
calci.html file is 
<template>
<ligtning-card title="Calci" icon-name="standard:formula">
<ligtning-layout multiple-rows>
<lightning-layout-item size="12"  padding="around-medium">
<lightning-input type="number" name="FirstNumber"></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-input type="number" name="SecondNumber"> </lightning-input>
        </lightning-layout-item>
        <lightning-layout-item size="12" padding="around-medium"> 
<lightning-button-group>
<lightning-button label="Add" icon-name="utility:add" icon:position="right"></lightning-button> 
<lightning-button label="Subtract" icon-name="utlity:dash"  icon:position="right"></lightning-button>
<lightning-button label="Multiply" icon-name="utlity:close" icon:position="right"></lightning-button>
<lightning-button label="Divide" icon-name="utlity:magicwand" icon:position="right"></lightning-button>
</lightning-button-group>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-formated-text value={}></lightning-formated-text>
</lightning-layout-item>
</ligtning-layout>
</ligtning-card>
</template>
--------------------------------------------------------------------------
calci.js-meta.xml file is 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="calci">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <description> Simple calculator app build with LWC</description>
    <targets>
    <target> lightning__AppPage  </target>
    <target> lightning__HomePage</target>
    <target> lightning_RecordPage</target>
    </targets>
</LightningComponentBundle>

Hi guys!

I am getting the below error on this test. class:

Error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

Code:

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        Account acc = new Account();
        acc.name= 'test';
        insert acc;
        
        Product2 newProd = new Product2 (Name = 'Test Product', ProductLine__c ='Test Product Line');
		insert newProd;
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;    
        
    	Pricebook2 customPB = new Pricebook2(Name='Test Product', isActive=true);
        insert customPB;
        
        PriceBookEntry pbEntry = new PriceBookEntry(UnitPrice = 100.00, PriceBook2Id = customPB.Id, Product2Id = newProd.Id, IsActive = true, UseStandardPrice = false);
		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select custombox__c from Account limit 1];
        Test.stopTest();
         }
}
Can anyone help with this? Any hints would be appreciated! 
public class AccountSelectContact{
    public List<WrapAccount> wrapAccList{get;set;}
    public List<Account> selectedAccounts{get;set;}
    public List<Contact> conList{get;set;}
    public AccountSelectContact(){
        if(wrapAccList== null){
            wrapAccList= new List<WrapAccount>();
          List<Account> accList=[select id, name,(select id,name,phone from contacts) from Account];
            for(Account a: accList){
                wrapAccList.add(new WrapAccount(a));
            }
        }
        system.debug('wrapAccList++'+wrapAccList);
    }
    public void processSelected(){
        wrapAccList= new List<WrapAccount>();
        selectedAccounts= new List<Account>();
        conList=[select id,name,phone from Contact where id IN: accList];
        for(WrapAccount w:conList){
            if (w.selected==true){
              selectedAccounts.add(w.conList);
            }
        }
    }
    public class WrapAccount{
        public Account acc{get;set;}
        public Boolean selected{get;set;}
        public WrapAccount(Account a){
            this.acc=a;
            this.selected=false;
        }
    }
}