• Prakhyat sapra
  • NEWBIE
  • 40 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 51
    Questions
  • 30
    Replies
  global void execute(Database.BatchableContext BC, list<case> caseList){
        set<Id> getIDs = new Set<Id>();
        Map<Id,Id> caseWithCasePlanIdMap = new Map<Id,Id>();
        Map<Id, List<String>> casePlanWithGoalsMap = new Map<Id, List<String>>();
       
        for(Case cse : caseList){
            if(cse.Case_Plans__r != null && cse.Case_Plans__r.size() >0){
                caseWithCasePlanIdMap.put(cse.id, cse.Case_Plans__r[0].Id);
            }
        }
        system.debug('caseWithCasePlanIdMap'+caseWithCasePlanIdMap);
        Map<Id, case> caseMap = new Map<Id, case>(caseList);
        System.debug('caseMap'+caseMap);
        for(caseman__Goal__c goal : [SELECT Id,Name, caseman__CasePlan__c, caseman__Status__c FROM caseman__Goal__c 
                                     where caseman__CasePlan__c IN: caseWithCasePlanIdMap.values() AND caseman__Status__c !='Completed']){ // 'a0SM000000EBStkMAH' ]){
                                         System.debug('caseWithCasePlanIdMap.values()'+caseWithCasePlanIdMap.values());
                                         System.debug('goal'+goal);
                                         if(!casePlanWithGoalsMap.containskey(goal.caseman__CasePlan__c)){
                                             casePlanWithGoalsMap.put(goal.caseman__CasePlan__c, new List<String>());
                                         }
                                         casePlanWithGoalsMap.get(goal.caseman__CasePlan__c).add(goal.Name);
                                         casePlanWithGoalsMap.get(goal.caseman__CasePlan__c).add(goal.caseman__Status__c);
                                     }
        System.debug('casePlanWithGoalsMap'+casePlanWithGoalsMap);
        
        CaseSevenDayFollowUpEmailBatch.afterSevenDaysEmail(caseList,casePlanWithGoalsMap);

 global static void afterSevenDaysEmail(List<case> CaseList,  Map<Id, List<String>> casePlanData){
        System.debug('casePlanData'+casePlanData);
        // for(case cas : CaseList){
        //  for(caseman__CasePlan__c  c : cas.Case_Plans__r){
        // for(caseman__Goal__c  go :c.caseman__Goals__r){
        // List<caseman__CasePlan__c> casePlanList =[Select id, Name, caseman__Status__c From caseman__CasePlan__c WHERE caseman__Status__c!= 'Completed'];
        Integer casePlanLength= casePlanData.size();
        
        System.debug('casePlanLength'+casePlanLength);
        // }
        //}         
        // } 
        if(casePlanData.size() > 0){ //casePlanLength
            system.debug('casePlanData.size()'+casePlanData.size());
            //  Set<Id> casePlanId = new Set<Id>();
            
            
            Set<id> goalIdSet = new Set<Id>();
            for(case ca :CaseList){
                for(caseman__CasePlan__c casePlan1 : ca.Case_Plans__r){
                    System.debug('caseman__Goals__r'+casePlan1.caseman__Goals__r);
                    for(caseman__Goal__c goal : casePlan1.caseman__Goals__r){
                        
                        System.debug('goal - ' + goal);
                        goalIdSet.add(goal.Id);
                    }
                    
                    Map<id,List<caseman__ActionItem__c>> actionItemMap = new Map<id,List<caseman__ActionItem__c>>();
                    List<caseman__ActionItem__c> actionItemList = [Select Id,Name,caseman__Goal__c,caseman__Status__c
                                                                   from caseman__ActionItem__c where caseman__Goal__c =: goalIdSet];
                    System.debug('actionItemList'+actionItemList);
                    for(caseman__ActionItem__c item : actionItemList){
                        if(actionItemMap.containsKey(item.caseman__Goal__c))
                        {   
                            actionItemMap.get(item.caseman__Goal__c).add(item);
                            
                        }
                        else 
                        {   
                            actionItemMap.put(item.caseman__Goal__c,new list<caseman__ActionItem__c>{item}); 
                        }
                    }        
                    String casePlanStatus = '';
                        String caseGoalStatus = '';
                        if(iterCase.Case_Plans__r.size() > 0) {
                            casePlanStatus = '<br/>'+iterCase.Case_Plans__r[0].caseman__Status__c+'<br/>';
                            System.debug('casePlanStatus'+casePlanStatus);
                            System.debug('casePlanData - ' + casePlanData);
                            if(casePlanData.size() > 0){
                              //  System.debug('casePlanData - ' + casePlanData.get('caseman__Status__c'));
                                  caseGoalStatus = '<br/>'+casePlanData[1]+'<br/>';
                                System.debug('caseman__Goal__c.caseman__Status__c'+caseman__Goal__c.caseman__Status__c);
                                 System.debug('caseGoalStatus'+caseGoalStatus);
                            }
                        }
}
}



 
i have one chackbox type field in account. & if chackbox is false the account owner != contact owner & if true account owner != contact owner through trigger?????
How to write schedulable Batch class to send email on week,1st month,3rd month,6thmonth,9thmonth,12thmonth from createdDate???
Send email to those records the records that past 7days, 30days,90days,180,days,9 month & 1year through shaduled batch class 
how can i insert the a lead record through apex class?
I have to make a lwc component take 4 inputs from the screen for the obiect Lead. then on the click of save button it will direct to new component in this component. I need to fetch all the details which I saved in the previous screen. 
 
import { LightningElement } from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
import LeadObject from '@salesforce/schema/Lead';
import LeadLastName from '@salesforce/schema/Lead.LastName';
import LeadEmail from '@salesforce/schema/Lead.Email';
import LeadCompany from '@salesforce/schema/Lead.Company';
import LeadStatus from '@salesforce/schema/Lead.Status'
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LeadForm extends LightningElement {
lastName = '';
emailId='';
Company='';
status= '';
LeadChangeVal(event) {
console.log(event.target.label);
console.log(event.target.value);
if(event.target.label=='Last Name'){
this.lastName = event.target.value;
}
if(event.target.label=='Company'){
this.Company = event.target.value;
}
if(event.target.label=='Email'){
this.emailId = event.target.value;
}
if(event.target.label=='Status'){
this.Status = event.target.value;
}
}
insertLeadAction(){
const fields = {};
fields[LeadLastName.fieldApiName] = this.lastName;
fields[LeadCompany.fieldApiName] = this.Company;
fields[LeadEmail.fieldApiName] = this.emailId;
fields[LeadStatus.fieldApiName] = this.Status;
const recordInput = { apiName: LeadObject.objectApiName, fields };
createRecord(recordInput)
.then(Leadobj=> {
this.LeadId = Leadobj.id;
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Lead record has been created',
variant: 'success',
}),
);
})
.catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error creating record',
message: error.body.message,
variant: 'error',
}),
);
});
}
value = 'inProgress';
get options() {
return [
{ label: 'Open - Not Contacted ', value: 'Open - Not Contacted' },
{ label: ' Working - Contacted ', value: 'Working - Contacted' },
{ label: 'Closed - Converted ', value: 'Closed - Converted' },
{ label: 'Closed - Not Converted ', value: 'Closed - Not Converted ' },
];
}
handleChange(event) {
}
}
I have 1 org in which i search any user that user detail shows on the next page ?? through flow in salesforce
Open pdf which is uploaded in the document in Salesforce classic & i have to create the aura component in which I have to create the button by clicking the button the pdf will open in the new tab????
public static List<ProductWrapper> getFilterProduct(String familyname,String searchtext){
        String filter ='SELECT Product2.Id,Name,Product2.Image_ID__c,Product2.Family,UnitPrice '
                         +' FROM PricebookEntry WHERE PriceBook2.IsStandard=true ';
         List<PricebookEntry> filterList;
        if(familyname =='All') { 
            filter+= 'AND Product2.Family != NULL AND Name LIKE \'%' + searchtext + '%\'';
        } else {   //get the filtered list 
            filter+= 'AND Product2.Family= \''+familyname +'\' AND Name LIKE \'%' + searchtext + '%\'';
        }
        filterList = DataBase.query(filter);
        List<ProductWrapper> wrapList = new List<ProductWrapper>();
         ProductWrapper wrap;    
        for(PricebookEntry prod : filterList){
            wrap = new ProductWrapper();
            wrap.id = prod.Product2.Id;
            wrap.name=prod.Name;
            wrap.ImageId=prod.Product2.Image_ID__c;
            wrap.Family=prod.Product2.Family;
            wrap.Price=prod.UnitPrice;
            wraplist.add(wrap);
        }
        return wraplist;
    }
    
what is the query for getting account whose related contact is more then 2
write a batch class in which the contacts of all the accounts should be only 2.if more than 2 then it bocomes 2, or if less then it becomes2???????
getting account & there related contact through soql queary in the salesforce???
what will be the formula in which i can take out the date from createdDate in the formula field of the salesforce????????/
i have created the connected app for integraction???

 global static List<Account> getAccountWith(){
        // List<ResponseWrapper> responseWrapperList = new List<ResponseWrapper>();
        RestRequest accountRequest = restContext.request;
        String accountRequestURI = accountRequest.requestURI;  
        Date accountLimit = Date.valueOf(accountRequestURI.substring(accountRequestURI.lastIndexOf('/')+1));
        System.debug('accountLimit'+ accountLimit);
        Date dt= accountLimit;
        System.debug('dt'+dt);
        Date myDate = date.newinstance(dt.year(), dt.month(), dt.day());
        System.debug('myDate'+myDate);
        List<Account> accountList =[SELECT id, name, CreatedDate FROM Account WHERE CreatedDate=:myDate];
        System.debug('accountList'+ accountList);
      
        return accountList;
        
    }

here is my code......
how to get all the account & related contact with parameter start date from the apex integration & wrapper class ?????????
I have to replace the endpoint which is in the custom metadata & I i have to replace that endpoint by using the apex 
how can i code for call this custom metadata in the apex class???User-added image
how to find the & replace the sting in the custom metadata in the salesforce??????????????
   fireSearchBox : function(component,event,helper){
        var searchBox;
        console.log('enter123456');
      
            //var value = searchBox.getSource().get("v.value");
        
        var action = component.get("c.search");
     action.setParams({"searchBox" :searchBox});
        action.setCallback(this,function(response){
            var state= response.getState();
            console.log('state',state);
            if (state=== "SUCCESS"){
                var response= response.getReturnValue();
                console.log('response',response);
                component.set("v.searchBoxs",response.getReturnValue());
            } 
            // component.set("v.productWrapper", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
    
create the aura component for account with 4 fields & a save button in the aura component ???
Create the opportunity whose state is closewon & account is !null then update closedate__c on account as todat date by trigger handler ??
  global void execute(Database.BatchableContext BC, list<case> caseList){
        set<Id> getIDs = new Set<Id>();
        Map<Id,Id> caseWithCasePlanIdMap = new Map<Id,Id>();
        Map<Id, List<String>> casePlanWithGoalsMap = new Map<Id, List<String>>();
       
        for(Case cse : caseList){
            if(cse.Case_Plans__r != null && cse.Case_Plans__r.size() >0){
                caseWithCasePlanIdMap.put(cse.id, cse.Case_Plans__r[0].Id);
            }
        }
        system.debug('caseWithCasePlanIdMap'+caseWithCasePlanIdMap);
        Map<Id, case> caseMap = new Map<Id, case>(caseList);
        System.debug('caseMap'+caseMap);
        for(caseman__Goal__c goal : [SELECT Id,Name, caseman__CasePlan__c, caseman__Status__c FROM caseman__Goal__c 
                                     where caseman__CasePlan__c IN: caseWithCasePlanIdMap.values() AND caseman__Status__c !='Completed']){ // 'a0SM000000EBStkMAH' ]){
                                         System.debug('caseWithCasePlanIdMap.values()'+caseWithCasePlanIdMap.values());
                                         System.debug('goal'+goal);
                                         if(!casePlanWithGoalsMap.containskey(goal.caseman__CasePlan__c)){
                                             casePlanWithGoalsMap.put(goal.caseman__CasePlan__c, new List<String>());
                                         }
                                         casePlanWithGoalsMap.get(goal.caseman__CasePlan__c).add(goal.Name);
                                         casePlanWithGoalsMap.get(goal.caseman__CasePlan__c).add(goal.caseman__Status__c);
                                     }
        System.debug('casePlanWithGoalsMap'+casePlanWithGoalsMap);
        
        CaseSevenDayFollowUpEmailBatch.afterSevenDaysEmail(caseList,casePlanWithGoalsMap);

 global static void afterSevenDaysEmail(List<case> CaseList,  Map<Id, List<String>> casePlanData){
        System.debug('casePlanData'+casePlanData);
        // for(case cas : CaseList){
        //  for(caseman__CasePlan__c  c : cas.Case_Plans__r){
        // for(caseman__Goal__c  go :c.caseman__Goals__r){
        // List<caseman__CasePlan__c> casePlanList =[Select id, Name, caseman__Status__c From caseman__CasePlan__c WHERE caseman__Status__c!= 'Completed'];
        Integer casePlanLength= casePlanData.size();
        
        System.debug('casePlanLength'+casePlanLength);
        // }
        //}         
        // } 
        if(casePlanData.size() > 0){ //casePlanLength
            system.debug('casePlanData.size()'+casePlanData.size());
            //  Set<Id> casePlanId = new Set<Id>();
            
            
            Set<id> goalIdSet = new Set<Id>();
            for(case ca :CaseList){
                for(caseman__CasePlan__c casePlan1 : ca.Case_Plans__r){
                    System.debug('caseman__Goals__r'+casePlan1.caseman__Goals__r);
                    for(caseman__Goal__c goal : casePlan1.caseman__Goals__r){
                        
                        System.debug('goal - ' + goal);
                        goalIdSet.add(goal.Id);
                    }
                    
                    Map<id,List<caseman__ActionItem__c>> actionItemMap = new Map<id,List<caseman__ActionItem__c>>();
                    List<caseman__ActionItem__c> actionItemList = [Select Id,Name,caseman__Goal__c,caseman__Status__c
                                                                   from caseman__ActionItem__c where caseman__Goal__c =: goalIdSet];
                    System.debug('actionItemList'+actionItemList);
                    for(caseman__ActionItem__c item : actionItemList){
                        if(actionItemMap.containsKey(item.caseman__Goal__c))
                        {   
                            actionItemMap.get(item.caseman__Goal__c).add(item);
                            
                        }
                        else 
                        {   
                            actionItemMap.put(item.caseman__Goal__c,new list<caseman__ActionItem__c>{item}); 
                        }
                    }        
                    String casePlanStatus = '';
                        String caseGoalStatus = '';
                        if(iterCase.Case_Plans__r.size() > 0) {
                            casePlanStatus = '<br/>'+iterCase.Case_Plans__r[0].caseman__Status__c+'<br/>';
                            System.debug('casePlanStatus'+casePlanStatus);
                            System.debug('casePlanData - ' + casePlanData);
                            if(casePlanData.size() > 0){
                              //  System.debug('casePlanData - ' + casePlanData.get('caseman__Status__c'));
                                  caseGoalStatus = '<br/>'+casePlanData[1]+'<br/>';
                                System.debug('caseman__Goal__c.caseman__Status__c'+caseman__Goal__c.caseman__Status__c);
                                 System.debug('caseGoalStatus'+caseGoalStatus);
                            }
                        }
}
}



 
write a batch class in which the contacts of all the accounts should be only 2.if more than 2 then it bocomes 2, or if less then it becomes2???????
getting account & there related contact through soql queary in the salesforce???
If i create project in salesforce, it should get create in jira 

global with sharing class Jiraproject {

global static void createproject(string Name) {
       
       JSONGenerator gen = JSON.createGenerator(true);

        gen.writeStartObject();
        gen.writeStringField('Name', Name);
        //gen.writeStringField('Id',Id);
        //gen.writeStringField('status__c',status__c);
        gen.writeEndObject();   
    String jsonString = gen.getAsString();
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('url');
request.setMethod('POST');

String username = 'kh@abc.com ';
String password = ' PcuTBIDoQ96784';
       Blob headerValue = Blob.valueOf(username + ':' + password);
    String authorizationHeader = 'Basic ' +
     EncodingUtil.base64Encode(headerValue);
     request.setHeader('Authorization', authorizationHeader);

request.setHeader('Content-Type','application/json;charset=UTF-8');
 // Set the body as a JSON object
 request.setBody (jsonString);

HttpResponse response = http.send(request);

// If the request is successful, parse the JSON response.
if(response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
    
}
 
}
 can anyone guideme? Thanks in advance
how can i code for call this custom metadata in the apex class???User-added image
   fireSearchBox : function(component,event,helper){
        var searchBox;
        console.log('enter123456');
      
            //var value = searchBox.getSource().get("v.value");
        
        var action = component.get("c.search");
     action.setParams({"searchBox" :searchBox});
        action.setCallback(this,function(response){
            var state= response.getState();
            console.log('state',state);
            if (state=== "SUCCESS"){
                var response= response.getReturnValue();
                console.log('response',response);
                component.set("v.searchBoxs",response.getReturnValue());
            } 
            // component.set("v.productWrapper", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
    
The user creates the "Revenue" record and enters the Start Date, End Date, Price and Quantity.

If the total run time (End Date - Start Date) spans across more than one calendar month,
then Child Monthly Revenue will automatically be created.
Each Child will be broken out by calendar month and the Quantity will be divided
evenly by the number of days in each month.
Upon Save - the Total Amount gets calculated: (Quality*Price) Also, the system will
automatically create child Monthly Revenue records based on the following:

1. NO. of children would: no. of the month from Start Date to End Date.
2. The amount would be calculated as: (Total No. of Days in Current Month * Total Amount on
parent Revenue)/Total no of days from Start Date to End date on Revenue.
3. Start Date on Monthly Revenue: Start Date of the Current Month
4. End Date on Monthly Revenue: Last Date of the current Month ex. 31 for Jan, 28/29 For Feb
5. Revenue: Lookup of Revenue record
EXAMPLE:
The user enters the following data onto the Revenue record:
Start Date: 01/Oct/2018
End Date: 31/Dec/2018
Quantity: 100000
Price = 20
Monthly records would be created as:
# Total no. of Monthly records 3 (Oct, Nov, Dec), and total no of days: 92
1.
Oct 2018 (31 days)
Quantity = (31*100000)/92
Price = 20
Amount = Quantity*Price
Start Date = 01/Oct/2018
End Date = 31/Oct/2018

2.
Nov 2018 (30 days)
Quantity = (30*100000)/92
Price = 20
Amount = Quantity*Price
Start Date = 01/Nov/2018
End Date = 30/Nov/2018

3.
Dec 2018 (31 days)
Quantity = (31*100000)/92
Price = 20
Amount = Quantity*Price
Start Date = 01/Dec/2018
End Date = 31/Dec/2018
In the Visit__c object, if more than 2 visit are made in the name of the same owner, then the error is given that you can't create more than 2 visit  by the same owner ????by trigger
In the Visit__c object, if more than 2 visit are made in the name of the same oner, then the error is given that you can't create more than 2 visit  by the same onner ????by trigger
how to merge ID in the hyperlink in the salesforce???
when we run the trigger on the visit__c then the visit__c name is already update by self????
how to make formula for visit-{0001} in the formula(text) in the salesforce???
if account  billing address is update then related contact mailingaddress is also update???
if account billing address is update then the contacts mailing address is also update & use the old map in this???
Hi Team,


Write a batch class for to delete all contacts of accounts where Account field : active__c="yes" ?


Please give me the reply to above scenario....

Regards
Lakshmi