• VICKY_SFDC
  • NEWBIE
  • 100 Points
  • Member since 2019


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 50
    Replies

I have Lightning Aura Component Name as caseList3

not passing selected case record id in js controller

below is the code (YOU CAN CHECK IN BROWSER BY CLTR+SHIFT+i) so it show selected record Id

as below line

console.log("Selected Case Id: " + selectedCaseId);

 

Now i want an lwc component which will take this Selected record Id as Input and display case and associated product details

 

 

My lightning components working perfectly

you can copy and test in your org

 

only issue i am getting with lwc

 

My Linghtning component code

APEX

public with sharing class CaseListController {
    public CaseListController() {

    }
    @AuraEnabled
    public static List<Case> getCases() {
        
         return [SELECT Id, Subject FROM Case Order By createdDate DESC LIMIT 5];
             
    }}

 

COMPONENT

 

 

caseList3.cmp

 

<aura:component controller="CaseListController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global">
    <aura:attribute name="caseList" type="Case[]" />
    <aura:attribute name="selectedCaseId" type="String" />
    <aura:attribute name="selectedRecordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.loadCases}" />
   
    <div class="slds-card">
        <div class="slds-card__header slds-grid">
            <h2 class="slds-text-heading_medium slds-col">Case Information</h2>
        </div>
        <div class="slds-card__body">
            <ul class="slds-list_dotted">
                <aura:iteration items="{!v.caseList}" var="caseRecord">
                    <li class="slds-p-around_small slds-box slds-box_small">
                        <p class="slds-text-title"><strong>Case Number:</strong> {!caseRecord.CaseNumber}</p>
                        <p class="slds-text-title"><strong>Subject:</strong> {!caseRecord.Subject}</p>
                        <p><strong>Description:</strong> {!caseRecord.Description}</p>
                        <!-- Add more case fields here -->
                        <button class="slds-button slds-button_brand select-case-button" data-caseid="{!caseRecord.Id}" onclick="{!c.selectCase}">Select Case&#128512;</button>
                    </li>
                </aura:iteration>
            </ul>
        </div>
    </div>
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
 

 

 

caseList3Controller.js

 

({
    selectCase: function (component, event, helper) {
        var selectedCaseId = event.currentTarget.getAttribute("data-caseid");
        component.set("v.selectedCaseId", selectedCaseId);
        console.log("Selected Case Id: " + selectedCaseId);
        var messagePayload = {
            selectedCaseId: selectedCaseId
        };
        var messageContext = component.find("workspace").getMessageContext();
        var message = {
            recordId: component.get("v.recordId"),
            messageBody: JSON.stringify(messagePayload)
        };
        messageContext
            .publishMessage(CASE_SELECTION_CHANNEL, message)
            .then(response => {
                console.log("Message published successfully");
            })
            .catch(error => {
                console.error("Error publishing message: " + error);
            });
    },
    loadCases: function (component, event, helper) {
        var action = component.get("c.getCases");
        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var caseRecords = response.getReturnValue();
                component.set("v.caseList", caseRecords);
            } else {
                console.error("Error fetching case data: " + state);
            }
        });
        $A.enqueueAction(action);
    },
    handleRecordSelection: function(component, event, helper) {
        var selectedRecordId = event.getParam("recordId");
        component.set("v.selectedRecordId", selectedRecordId);
    }
   
})
 

 

 

Senario:

Total Numer of Case=19

Case with Overtime=16


Now

16/19,,so Green Arrow Image display in Lightning Component APP

if its 

20/19  (Or more),,,red arrow image should display in LIGHTNING COMPONENT UI


Any Resource 
Any Trailhead link will be very helpful for me

thanks in advance
MY REQUIREMENT IS,,if i click on case owner icon  all the cases status as  open, close, escalated etc were shown to me 

in LWC or Lightning UI


I wrote a apex code as well,,,


public with sharing class caseAgentCount {
    
    @AuraEnabled
    public Static Integer openCaseCount(){
        return[SELECT count() from Case Where Status!='Closed' And OwnerId=:UserInfo.getUserID()];
    }
    
    @AuraEnabled
    public Static Integer closeCaseCount(){
        return[SELECT count() from Case Where Status='Closed'And OwnerId=:UserInfo.getUserID()];
    }
    
    @AuraEnabled
    public Static Integer workingCaseCount(){
        return[SELECT count() from Case Where Status='working' And OwnerId=:UserInfo.getUserID()];
    }
    
     @AuraEnabled
    public Static Integer esclatedCaseCount(){
        return[SELECT count() from Case Where Status='Esclated' And OwnerId=:UserInfo.getUserID()];
    }
    
    @AuraEnabled
    public Static Integer holdCaseCount(){
        return[SELECT count() from Case Where Status='Hold' And OwnerId=:UserInfo.getUserID()];
    }
}
Senario:
NEED TO CREATE A TASK i.e MEETING INVITE  and THEN I HAVE TO SELECT MULTIPLE CONTACT AND SEND THAT EMAIL AT ONE SHOT TO ALL SELECTED CONTACTS

 
I have 2 users both have admin licience,,,Now Those account Whose indust is not null there Owner is User2.
As per my batch class At the end User should get some mail,I am not getting any email.

When i check Job its shown as completed.

BELOW CODE(JUST COPY AND PASTE AND CHECK):


global class Batch_Apex_Example_2 implements Database.Batchable<sobject>,Database.Stateful{
    public Map<Id,List<String>> accMap;
    global Batch_Apex_Example_2(){
        accMap=new Map<Id,List<String>>();
    }
    global Database.QueryLocator start(Database.BatchableContext bc){
        String query='Select id,name,ownerId from Account';
        return Database.getQueryLocator(query);   
    }
    
    global void execute(Database.BatchableContext bc,List<Account> scope){
        for(Account a:scope){
            if(accMap.containsKey(a.ownerId)){
                List<String> names=accMap.get(a.ownerId);
                names.add(a.name);
                accMap.put(a.ownerId,names);
            }else{
                List<String> names=new List<String>();
                names.add(a.name);
                accMap.put(a.ownerId,names);
            }
        }   
    }
    global void finish(Database.BatchableContext bc){
        Set<Id> keys=accMap.keySet();
        List<User> users=[Select id,email from user where id in:keys];
        Map<Id,String> userMap=new Map<Id,String>();
        for(User u:users){
            userMap.put(u.id,u.email);
        }
        System.debug('userMap===========>'+userMap);
        List<Messaging.Email> emails=new List<Messaging.Email>();
        for(Id k:keys){
            Messaging.SingleEmailMessage msg=new Messaging.SingleEmailMessage();
            List<String> accounts=accMap.get(k);
            String body='';
            for(String a:accounts){
                body=body+'<br/>'+a;
            }
            msg.setSubject('Your Accounts');
            msg.setHtmlBody(body);
            String email=userMap.get(k);
            String[] toadd=new String[]{email};
                msg.setToAddresses(toadd);
            emails.add(msg);
        }
        Messaging.sendEmail(emails);
    }
}


/*FOR EXECUTING BATCH CLASS
1)cltr+E
2)Batch_Apex_Example_2 be=new Batch_Apex_Example_2();
Id jobId=Database.executeBatch(be,5);
3)Execute
*/
REQUIREMENT:

WE HAVE A CASE WITH ACCOUNT,

IN CASE RELATED LIST ,WHEN WE CREATE AN OPPORTUNITY 
THEN IT  ACCOUNT NAME SHOULD BE AUTOMATIC UPDATED AS CASE ACCOUNT NAME.

ALSO WHEN I UPDATE THE CASE ACCOUNT FIELD,,IT SHOULD REFLECT IN THE RELATED OPPORTUNITY OBJECT
Here Case Is Parent and Opportunity is Child,,
1)When from Existing Case  [Without Parent Account],i create an opportunity and then select Parent account the its reflect on Opportunity Parent as well
2)But Update is Not Working,,when i change case parent  Account its not reflecting in Opportunity Acccount field.
Below is the Trigger:

public class Data {
    public static void InsertMethod(list<Case> newCas){
         set<Id> lstAccId = new set<Id>();
                set<Id> lstOppId = new set<Id>();//Opportunity Parent
       
        for(Case cas:newCas){
            if(cas.AccountId!=null){
             lstAccId.add(cas.AccountId);  
            }
           
            if(cas.Opportunity__c!=null){
             lstOppId.add(cas.Opportunity__c);  
            }
        }
            list<Account> lstAcc = [Select id from Account where id IN :lstAccId];
            list<Opportunity> lstOpp=[Select id,AccountId from Opportunity where id IN :lstOppId];
       
        for(Account s :lstAcc){
           
            for(Opportunity op:lstOpp){
                op.AccountId=s.Id;
            }
        }
       
        update lstOpp; 
    }
   



    public static void UpdateMethod(list<Case> newCas,map<Id,Case> oldmap){
         set<Id> lstAccId = new set<Id>();
                set<Id> lstOppId = new set<Id>();//Opportunity Parent
       
    
    for(Case cas:newCas ){
            if(cas.AccountId!=null && cas.AccountId!=oldmap.get(cas.id).AccountId){
             lstAccId.add(cas.AccountId);  
            }
           
            if(cas.Opportunity__c!=null && cas.Opportunity__c!=oldmap.get(cas.id).Opportunity__c){
             lstOppId.add(cas.Opportunity__c);  
            }
        }
   
   list<Account> lstAcc = [Select id from Account where id IN :lstAccId];
            list<Opportunity> lstOpp=[Select id,AccountId from Opportunity where id IN :lstOppId];
       
        for(Account s :lstAcc){
           
            for(Opportunity op:lstOpp){
                op.AccountId=s.Id;
            }
        }
       
        update lstOpp; 
    }
       
}

Trigger:

trigger TriggerOnCase on Case (after insert,after update) {
      If(Trigger.IsAfter){
        If(Trigger.IsInsert){
         Data.InsertMethod(Trigger.new);
        }
        If(Trigger.IsUpdate){
        Data.UpdateMethod(Trigger.new,Trigger.oldMap);
        }
    }
}
 
Senario:

Opportunity is child and case is Parent Object.
When New Opportunity Is Created along with associated Account,,,and associated case object.
that account Lookup name should be autoPopulate in Case Object of Account Lookup Field.

I create a Lookup Relation where Opportunity is Child and Case is Parent.


ERROR:
TriggerOnOpportunity: execution of AfterInsert caused by: System.ListException: Duplicate id in list: 5005g00000DAPbrAAH Class.Data.insertOpportunity: line 16, column 1 Trigger.TriggerOnOpportunity: line 3, column 1

FIELDS IN HANDLER CLASS:
MY_ACC__c-->On case Object(Text(20))
Case__c-->Looupfield on Opportunity



Handler class:


public class Data{
    
    
    public static void insertOpportunity(List<opportunity> oppList)
    {
        List<opportunity> opp = [select id,Case__r.id,Case__r.MY_ACC__c,Account.name, Accountid from opportunity where id=:oppList ];
        system.debug(opp[0].Case__r.id);
        system.debug('oppList'+oppList);
        if(opp[0].Case__r.id != null){
        List<case> casselist = [select id, MY_ACC__c from case where id=:opp[0].Case__r.id LIMIT 1];
            case c = new case();
            c.Id = casselist[0].id;
            c.MY_ACC__c = opp[0].Account.name;
            casselist.add(c);
      //  casselist[0].MY_ACC__c = opp[0].Account.name;
        Upsert casselist;
        }
    }
    
}


Trigger Class:

trigger TriggerOnOpportunity on Opportunity (after insert, after update) {
    if (Trigger.isAfter    && Trigger.isInsert || Trigger.isUpdate){     
    Data.insertOpportunity(Trigger.new);
    }
       
   }
SENARIO:

Employee is parent and emplayment is child both are custom and lookup r/s.

Now In child  there is a Amount field(Currency field ) is there now assume c1,c2,c3 amount field is 1000 of each,,,,the toal of amount should be reflect on parent field i.e Total(Currency field with default value 0). 

Now i want to rollup should work for all these actions     insert,update,delete,Undelete
employee==>API:  junebatch2021__Employee__c

employee payment==>API: junebatch2021__EMP_PAYMENT__c

Both in Lookup r/s where employee is parent.

Now,
employee payment there is a amount field soas many time i enter amount corresponding to there employee it will rollup and Relect
the SUM IN 

Total field :API==>junebatch2021__Total__c
WHICH IS CURRENCY FIELD ON PARENT OBJECT WITH DEFAULT VALUE 0.


I AM POSTING ERROR AND BELOW THAT MY HANDLER AND TRIGGER,,,
IF ANY ONE CAN GIVE SOME VALUABLE FEEDBACK ,,THAT WOULD BE VERY HELPFULL.


Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger junebatch2021.deleteAction caused an unexpected exception, contact your administrator: junebatch2021.deleteAction: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Class.junebatch2021.deleteAction.del: line 3, column 1





Handler:

public class EmpLaymentHelper {
    public static void beforeInsert(List<junebatch2021__EMP_PAYMENT__c> payments){
        for(junebatch2021__EMP_PAYMENT__c p:payments){
            if(p.junebatch2021__Employee__c==null){
                p.junebatch2021__Employee__c.addError('SELECT THE EMPLOYEE');
            }
        }
    }
    public static void afterInsert(List<junebatch2021__EMP_PAYMENT__c> payments){
        Map<Id,List<junebatch2021__EMP_PAYMENT__c>> payMap=new Map<Id,List<junebatch2021__EMP_PAYMENT__c>>();
        try{
        for(junebatch2021__EMP_PAYMENT__c p:payments){
            ID empId=p.junebatch2021__Employee__c;
           Boolean flag=payMap.containsKey(empId);
           List<junebatch2021__EMP_PAYMENT__c> payList=new List<junebatch2021__EMP_PAYMENT__c>();
            
            if(flag==True){
              payList=payMap.get(empId);
              payList.add(p);
              payMap.put(empId,payList);  
            }else{
                payList.add(p);
              payMap.put(empId,payList);   
            }
        }
        
        //LOGIC OF SUM IN CHILD
        
       Map<Id,Decimal> empMap=new Map<Id,Decimal>();
        for(Id key:payMap.keySet()){
            List<junebatch2021__EMP_PAYMENT__c> pays=payMap.get(key);
            Decimal sum=0;
            for(junebatch2021__EMP_PAYMENT__c pa:pays){
                sum=sum+pa.junebatch2021__EMP_AMOUNT__c;
            }
            empMap.put(key,sum);
        }
//NOW REFLECT THAT UPDATE IN PARENT
        
List<junebatch2021__Employee__c> employees=[Select id,junebatch2021__Total__c from junebatch2021__Employee__c where id in:empMap.keySet()];        
        for(junebatch2021__Employee__c e:employees){
          e.junebatch2021__Total__c=e.junebatch2021__Total__c+empMap.get(e.Id);  
        }       
update employees;
    } 
         catch(Exception e){
        e.getMessage();
    }
}
    
   
}



Trigger:

trigger EmpLaymentHelper on junebatch2021__EMP_PAYMENT__c (before insert,after insert,after update,after delete) {
    if(Trigger.isBefore && Trigger.isInsert){
        EmpLaymentHelper.beforeInsert(Trigger.new);
    }
    else{
        if(Trigger.isAfter && Trigger.isInsert){
            EmpLaymentHelper.afterInsert(Trigger.new);
        }
    }
}
Hi ,My requirement is I want to Create an Opportunity Record With Help Of Form,,

Requirement:
a)If i use any special chracter like "!@#$%^&*" in Name field it will throw an Custom Exception i.e ---->Special Chracter Not Allowed.

b)For type and StageName Field There should be a picklist field In Form.

c)There shoud be a custom checkbox field in form ,,so when we checked  and save in form,,,,,it will show as checked in Record as well

I ALREADY  Gone through multiple links ,,,didn't find the solution so m posing here


 
Hi,
My below LWCCODE IS WORKING FINE,,,I JUST WANT SOME SMALL MODIFICATIONs,,,AND ADD SOME VALIDATIONS

Like in Name if i will give ivalid input it will throw the error “INVALID NAME” something like that

And additionally i  want a checkbox field as well which will be add checkbox checked if in form checkbox is selected


A)dEFTECH.html:

<template>
<lightning-card title={cardTitle} icon-name="custom:custom85">
    <div class="slds-m-around_medium">
        <lightning-record-edit-form object-api-name="Opportunity" onsuccess={handleSuccess}>
            
            <lightning-messages>
            </lightning-messages>
            
            <lightning-input-field field-name="Name" pattern={name_validation}>
            </lightning-input-field>

<lightning-input-field field-name="Subject">
            </lightning-input-field>

            <lightning-input-field field-name="StageName">
            </lightning-input-field>

            <lightning-input-field field-name="CloseDate">
            </lightning-input-field>

            <lightning-input-field field-name="Type">
            </lightning-input-field>

           
 <!--Parent account for opportunity-->
            <lightning-input-field field-name="AccountId" value={recordId}>
            </lightning-input-field>
            <lightning-button
            class="slds-m-top_small"
            type="submit"
            label="Create new">
        </lightning-button>
         </lightning-record-edit-form>
    </div>   
</lightning-card>   
</template>


B) dEFTECH.js

import { LightningElement ,track,api} from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';//DISPLAY TOAST MESSAGE
export default class DEFTECH extends LightningElement {
    @api recordId;
    @track cardTitle='New Opportunity';
       
    handleSuccess (){//===>JUST COPY AND PASTE AS IT IS
        const evt = new ShowToastEvent({
            title: "Success!",
            message: "Congrats, Opportunity record has been successfully",
            variant: "success",
        });
        this.dispatchEvent(evt);
    }

}
 
FOR MY FOR MULA FIELD I CREATED A PICKLIST FIELD i.e Donated_above_10k__c where its values is yes,no,may be

According to my formula 
yes--->image1 display
no--->image 2
may be --->images 3
All images are uploaded in sratic resource

Here is the formula

CONTACT( Donated_above_10k__c ,
“Yes”, IMAGE("https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622553334000/GoldenBadge?", "Yes", 100, 100),
“No”, IMAGE(“https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622540671000/QuickCase2?”,”No”,16,16),
“IDK”, IMAGE(“https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622563356000/gg?”,”IDK”,16,16),
“”) 
IN VS STDIO getting this error while deploying the code,,,even i tried to authorize the org bt not able to perform that as well " unable to build lightning component source invalid suffix: json. "
I created contact_roles__c [type picklist] and opportunity__roles__c [type picklist] on contact and opportunity. 
Now i need to create a report where contact as parent and opportunity is child ,,,,where along with contact_roles__c [type picklist] the  opportunity__roles__c [type picklist] should be visible ,,,,,,,,,, in report.First i trued through Opportunity with Contact roles  and it didn't worked ,,ITS NOT SHOWING OPPORTUNITY AND CONTACT RECORDS.. Later i went to Report types-->Custom Report-->Contact and opportunity as parent and child,,and the selected that custom report but That also didn't Worked,,ITS NOT SHOWING OPPORTUNITY AND CONTACT RECORDS.. 
APEX:

public class OAuth_Box_Example {
    public Mydata__c data         {set;get;}
    public String code             {set;get;}
    public String accessToken       {set;get;}
    public String result             {set;get;}
    public String callbackurl         {set;get;}
    
    public  OAuth_Box_Example(){
        data=[Select id,ClientId__c,ClientSecret__c from Mydata__c where name='Box'];
        callbackurl='https://ap16.salesforce.com/apex/BoxResponse';
    }
    
    public PageReference requestCode(){
        String url='https://account.box.com/api/oauth2/authorize?';
        url=url+'response_type=code&client_id='+data.clientId__c;
        url=url+'&redirect_uri='+callbackurl;
        url=url+'&state=Vikas';
        PageReference p=new PageReference(url);
        return p;
    }
    
    public void readCode(){
        code=Apexpages.currentPage().getParameters().get('code');
    }
    public void requestToken(){
        String url='https://api.box.com/oauth2/token';        
        Http p=new Http();
        HttpRequest request=new HttpRequest();
        request.setEndpoint(url);
        request.setMethod('POST');
        String body='grant_type=autherization_code&code='+code;
        body=body+'&client_id='+data.ClientId__c;
        body=body+'&client_secret='+data.ClientSecret__c;
        request.setBody(body);
        HttpResponse response=p.send(request);
        String jsonBody=response.getBody();
        System.JSONParser jp=JSON.createParser(jsonBody);
        while(jp.nextToken()!=null){
            if(jp.getText()=='access_token'){
                jp.nextToken();
                accessToken=jp.getText();
            }
        }
        
    }    
}

VISUAL FORCE:

1) BoxResponse:

<apex:page controller="OAuth_Box_Example" action="{!readCode}">
    <apex:form >
        <apex:pageBlock title="Token & Action" id="pb">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Token" action="{!requestToken}" reRender="pb"/>
            </apex:pageBlockButtons>
            Client Id:{!data.ClientId__c}<br/><br/>
            CallbackSecret:{!data.ClientSecret__c}<br/><br/>
            RedirectUrl:{!callbackurl}<br/><br/>
            Code:{!code}<br/><br/>
            AccessToken:{!accessToken}
        </apex:pageBlock>
    </apex:form>
</apex:page>


2)Box_Home:

<apex:page controller="OAuth_Box_Example">
    <apex:form >
        <apex:pageBlock title="OAuth">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Submit" action="{!requestCode}"/>
            </apex:pageBlockButtons>
            Client Id:{!data.ClientId__c}<br/><br/>
            CallbackUrl:{!callbackurl}<br/><br/>
            State : Vikas
        </apex:pageBlock>
    </apex:form>
</apex:page>
The condition for my trigger is every wednessday at 6 pm get all the records from campaign object and based on the value of a field and call status from its related call history object... then send an email to those campaign members
Assume In an account opportunity is there then 2nd opportunity its pop up an An error else if no opportunity is there then automatic an opportunity will be created?
Whenever m insert a contact or  list of contact, same email and phone number popup an error of duplicate error
       Based on contact email and phone?
 
Account  picklist filed status__c changes to completed , when all fields are  not empty else status__c show as incomplete,,
If status__c changes to completed
,i want checkbox in all the related contact should be checked.
FOR MY FOR MULA FIELD I CREATED A PICKLIST FIELD i.e Donated_above_10k__c where its values is yes,no,may be

According to my formula 
yes--->image1 display
no--->image 2
may be --->images 3
All images are uploaded in sratic resource

Here is the formula

CONTACT( Donated_above_10k__c ,
“Yes”, IMAGE("https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622553334000/GoldenBadge?", "Yes", 100, 100),
“No”, IMAGE(“https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622540671000/QuickCase2?”,”No”,16,16),
“IDK”, IMAGE(“https://amazing-astro-230651-dev-ed--c.visualforce.com/resource/1622563356000/gg?”,”IDK”,16,16),
“”) 

I have Lightning Aura Component Name as caseList3

not passing selected case record id in js controller

below is the code (YOU CAN CHECK IN BROWSER BY CLTR+SHIFT+i) so it show selected record Id

as below line

console.log("Selected Case Id: " + selectedCaseId);

 

Now i want an lwc component which will take this Selected record Id as Input and display case and associated product details

 

 

My lightning components working perfectly

you can copy and test in your org

 

only issue i am getting with lwc

 

My Linghtning component code

APEX

public with sharing class CaseListController {
    public CaseListController() {

    }
    @AuraEnabled
    public static List<Case> getCases() {
        
         return [SELECT Id, Subject FROM Case Order By createdDate DESC LIMIT 5];
             
    }}

 

COMPONENT

 

 

caseList3.cmp

 

<aura:component controller="CaseListController"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global">
    <aura:attribute name="caseList" type="Case[]" />
    <aura:attribute name="selectedCaseId" type="String" />
    <aura:attribute name="selectedRecordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.loadCases}" />
   
    <div class="slds-card">
        <div class="slds-card__header slds-grid">
            <h2 class="slds-text-heading_medium slds-col">Case Information</h2>
        </div>
        <div class="slds-card__body">
            <ul class="slds-list_dotted">
                <aura:iteration items="{!v.caseList}" var="caseRecord">
                    <li class="slds-p-around_small slds-box slds-box_small">
                        <p class="slds-text-title"><strong>Case Number:</strong> {!caseRecord.CaseNumber}</p>
                        <p class="slds-text-title"><strong>Subject:</strong> {!caseRecord.Subject}</p>
                        <p><strong>Description:</strong> {!caseRecord.Description}</p>
                        <!-- Add more case fields here -->
                        <button class="slds-button slds-button_brand select-case-button" data-caseid="{!caseRecord.Id}" onclick="{!c.selectCase}">Select Case&#128512;</button>
                    </li>
                </aura:iteration>
            </ul>
        </div>
    </div>
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
 

 

 

caseList3Controller.js

 

({
    selectCase: function (component, event, helper) {
        var selectedCaseId = event.currentTarget.getAttribute("data-caseid");
        component.set("v.selectedCaseId", selectedCaseId);
        console.log("Selected Case Id: " + selectedCaseId);
        var messagePayload = {
            selectedCaseId: selectedCaseId
        };
        var messageContext = component.find("workspace").getMessageContext();
        var message = {
            recordId: component.get("v.recordId"),
            messageBody: JSON.stringify(messagePayload)
        };
        messageContext
            .publishMessage(CASE_SELECTION_CHANNEL, message)
            .then(response => {
                console.log("Message published successfully");
            })
            .catch(error => {
                console.error("Error publishing message: " + error);
            });
    },
    loadCases: function (component, event, helper) {
        var action = component.get("c.getCases");
        action.setCallback(this, function (response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var caseRecords = response.getReturnValue();
                component.set("v.caseList", caseRecords);
            } else {
                console.error("Error fetching case data: " + state);
            }
        });
        $A.enqueueAction(action);
    },
    handleRecordSelection: function(component, event, helper) {
        var selectedRecordId = event.getParam("recordId");
        component.set("v.selectedRecordId", selectedRecordId);
    }
   
})
 

 

 

@RestResource(urlmapping='/v1/Accounts/*')
global with sharing class MultipleRecords {
   
    @HttpGet
    global static list<Account> getAccounts(){
         
        RestRequest accRequest = RestContext.request;
        map<String,String> accReqParams = accRequest.Params;
        string rating = accReqParams.get('Rating');
        list<Account> listAcc = [Select id,Name,Rating from Account where Rating =: rating];
        return listAcc;

    }
       
}
>>Query in POSTMAN
https://kallam12-dev-ed.my.salesforce.com/services/apexrest/v1/Accounts/?Rating=Hot 

How to get both where rating is Hot and Cold?
I want to create more than 50,000 records in account object using code.Later I want to update Rating field to 'Warm' to all the records in present in account object.
  • October 08, 2021
  • Like
  • 0
Hi All,

Need help in file upload.
implementing through the below way

<lightning-input type="file" label="Attachment" accept="image/png, .zip" onchange={handleFilesChange} >
</lightning-input>

tried but not working.
Thanks.
I have 2 users both have admin licience,,,Now Those account Whose indust is not null there Owner is User2.
As per my batch class At the end User should get some mail,I am not getting any email.

When i check Job its shown as completed.

BELOW CODE(JUST COPY AND PASTE AND CHECK):


global class Batch_Apex_Example_2 implements Database.Batchable<sobject>,Database.Stateful{
    public Map<Id,List<String>> accMap;
    global Batch_Apex_Example_2(){
        accMap=new Map<Id,List<String>>();
    }
    global Database.QueryLocator start(Database.BatchableContext bc){
        String query='Select id,name,ownerId from Account';
        return Database.getQueryLocator(query);   
    }
    
    global void execute(Database.BatchableContext bc,List<Account> scope){
        for(Account a:scope){
            if(accMap.containsKey(a.ownerId)){
                List<String> names=accMap.get(a.ownerId);
                names.add(a.name);
                accMap.put(a.ownerId,names);
            }else{
                List<String> names=new List<String>();
                names.add(a.name);
                accMap.put(a.ownerId,names);
            }
        }   
    }
    global void finish(Database.BatchableContext bc){
        Set<Id> keys=accMap.keySet();
        List<User> users=[Select id,email from user where id in:keys];
        Map<Id,String> userMap=new Map<Id,String>();
        for(User u:users){
            userMap.put(u.id,u.email);
        }
        System.debug('userMap===========>'+userMap);
        List<Messaging.Email> emails=new List<Messaging.Email>();
        for(Id k:keys){
            Messaging.SingleEmailMessage msg=new Messaging.SingleEmailMessage();
            List<String> accounts=accMap.get(k);
            String body='';
            for(String a:accounts){
                body=body+'<br/>'+a;
            }
            msg.setSubject('Your Accounts');
            msg.setHtmlBody(body);
            String email=userMap.get(k);
            String[] toadd=new String[]{email};
                msg.setToAddresses(toadd);
            emails.add(msg);
        }
        Messaging.sendEmail(emails);
    }
}


/*FOR EXECUTING BATCH CLASS
1)cltr+E
2)Batch_Apex_Example_2 be=new Batch_Apex_Example_2();
Id jobId=Database.executeBatch(be,5);
3)Execute
*/
I have created an integration user account with name Integration User. How can I update the created by (ownerid) and last updated by fields with the details of this integration user while doing a bulk dml insert in apex? Right now its showing the logged in users name when the apex class is run.
 
// records to be updated received from json
jsonBody = '[{"count__c":"445", "downloads__c":"340"}, {"count__c":"440", "downloads__c":"240"}]';

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say: 445,440 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c> dataToInsert = new List<Data__c>();

// Loop through dList - inner loop
for(Data__c dRecords : dList) {
     for(Parent__c parentRecords : parentList) {         
          if(dRecords.count__c  == parentRecords.count__c) {
                dRecords.downloads__c  = parentRecords.downloads__c ;
                dataToInsert.add(dRecords );
           }
      } 
} 
insert dataToInsert;

 
A custom field Exec_Count_c of type Number is created on an Account object. An account record with value of "1" for a: Exec_Count_c is saved.

A workflow field update is defined on the Exec_Count_c field, to increment its value every time an account record is created or updated. The following trigger is defined on the account:

trigger ExecOrderTrigger on Account (before insert, before update, after insert, after update){ for (Account accountInstance: Trigger.New){ if (Trigger . isBefore) { accountInstance Exec_Count_c += 1; } System. debug (accountInstance.Exec_Count_c); } }
REQUIREMENT:

WE HAVE A CASE WITH ACCOUNT,

IN CASE RELATED LIST ,WHEN WE CREATE AN OPPORTUNITY 
THEN IT  ACCOUNT NAME SHOULD BE AUTOMATIC UPDATED AS CASE ACCOUNT NAME.

ALSO WHEN I UPDATE THE CASE ACCOUNT FIELD,,IT SHOULD REFLECT IN THE RELATED OPPORTUNITY OBJECT
Hi All,

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

I need some help and suggestion regarding the email alert when lead is not modified for 24 Hrs, i tried with the workflow alert and time based Triggers but it was not working, 
Workflow rule:-

Evaluation criteria:- Every time record is created & subsequently meet criteria

Formula:- LastmodifiedDate=Created Date

and Created a Timetrigger actions for 24 Hrs, but it did not fire

I have Faced a lot of issues with Workflows and Prosess Builders, so i need help for designing a Batch class When Lead  is Created and if the lead is not modified for 24Hrs it should send an Email alert
This is what i have come up with till now
global class Emailalertbatchclass implements Database.Batchable<sObject>, Schedulable, Database.Stateful {

    //Variable Section
    global FINAL String strQuery;
    global List<String> errorMessages = new List<String>();
    
    global Emailalertbatchclass() { 
        this.strQuery = getBatchQuery();
    }
    
    //Returns the Query String to Batch constructor to fetch right records.
    private String getBatchQuery() {
        String strQuery = 'SELECT Id, name, Owner.Email FROM Lead WHERE CreatedDate >= YESTERDAY'; 
        return strQuery;
    }
    
    //Batch Start method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(strQuery);
    }

    //Batch Execute method calls findCostForWoD method
    global void execute(Database.BatchableContext BC, List<sObject> scopeList) {
        System.debug(LoggingLevel.INFO, '== scopeList size ==' + scopeList.size());
        
        List<Lead> ld = (List<Lead>) scopeList;
        if(!ld.isEmpty()) { 
            List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
            for (Lead prod : ld)
            {               
                
                Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); 
                String[] toAddresses = new String[] {prod.Owner.Email};
                Message.setToAddresses(toAddresses); 
                Message.SaveAsActivity = false;
                mailList.add(Message);
                
            }
            if(!mailList.isEmpty()) {
                try{
                    Messaging.sendEmail(mailList);
                }
                catch (Exception ex) {
                    errorMessages.add('Unable to send email to Tech: '+ ex.getStackTraceString());
                }
            }
        }
    }  

    //Batch Finish method for after execution of batch work
    global void finish(Database.BatchableContext BC) { 
        AsyncApexJob aaj = [Select Id, Status, NumberOfErrors, JobItemsProcessed, MethodName, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id =:BC.getJobId()];
        
        // Send an email to the Apex job's submitter notifying of job completion.
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {aaj.CreatedBy.Email};
        mail.setToAddresses(toAddresses);
        mail.setSubject('JOB Salesforce Send Notification Batch: ' + aaj.Status);
        String bodyText='Total Job Items ' + aaj.TotalJobItems + ' Number of records processed ' + aaj.JobItemsProcessed + ' with '+ aaj.NumberOfErrors + ' failures.\n';
        bodyText += 'Number of Error Messages ' + errorMessages.size() + '\n';
        bodyText += 'Error Message' + String.join(errorMessages, '\n');
        mail.setPlainTextBody(bodyText);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
    
    //Method which schedules the ProductDownloadBatch
    global void execute(SchedulableContext sc) {        
        Emailalertbatchclass snInstance = new Emailalertbatchclass();
        ID batchprocessid = Database.executeBatch(snInstance);
    }
}
Any help would be Highly Appericiated 



 
Hi,
I have Company as a custom object, and Company Name as a Salesforce Defined Field in that object.
Can anyone help me to write validation Rule to prevent the duplicate of Company Name

Thanks,
Varalaxmi
 
Hi

I am using the following to validate an text field has email addresses entered in the correct format.  However I also need to ensure between each email address there is a ; seperator  

The regex I found onlne is :

NOT( REGEX(Custom_email_list__c , "([A-Za-z0-9]+([!#$%&'*+-/=?^_`{|}~]*[A-Za-z0-9]+)*@[A-Za-z0-9\\-]+(\\.[A-Za-z0-9\\-]+)*[ ]*[,;]?[ ]*)+" ))

which works well but still works without a ; between email addresses

How do I ensure ; is present and if not it will throw the validation error?

Many thanks in advance

Hi,

 

I have a string which I am decoding using base64Decode method, then am encoding it back using base64Encode. Then ultimately I should have the initial string, but in certain case its been truncated.

 

Any idea, why is this happening or am I missing here something?

 

Thanks.