• mukesh gupta
  • SMARTIE
  • 812 Points
  • Member since 2015
  • 4X Salesforce Certified

  • Chatter
    Feed
  • 20
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 108
    Questions
  • 200
    Replies
global class LoanOfficerBatch implements Database.Batchable<sObject> {
    public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, ConvertedOpportunityId, Name, Phone, Starting_Credit_Score__c, ' 
                          +  'Status, Enrolled_On__c, Est_Re_Pull_Date__c, Realtor_Name__c ' 
                          +   ' FROM Lead'; /*JMA:: add  ConvertedOpportunityId field*/ 
    public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1];

    global Database.QueryLocator start(Database.BatchableContext bc) {

        query += ' WHERE CreatedDate >= LAST_MONTH AND CreatedDate <= THIS_MONTH AND Loan_Officer_1a__c != null';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, list<Lead> allLeads) {
        
        //JMA:: Create a map of <Id, Opportunity>
        Map<Id,List<Opportunity>> OpptyMap = new Map<Id,List<Opportunity>>();
        //JMA:: Query Opportunities by using Lead.ConvertedOpportunityId. You need to first create a set of Id from Lead.ConvertedOpportunityId
        //JMA:: populate the map <Id, Opportunity>
        
        Map<Id,List<Lead>> leadMap = new Map<Id,List<Lead>>();
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMEssage>();
        if(allLeads != null && allLeads.size() > 0){
            for(Lead l: allLeads){
                if(!leadMap.containsKey(l.Loan_Officer_1a__c)){
                    leadMap.put(l.Loan_Officer_1a__c, new List<lead>());
                }
                leadMap.get(l.Loan_Officer_1a__c).add(l);
            }
        }
        if(leadMap.keySet().size() > 0){
            Map<Id,Contact> officers = new Map<Id,Contact>([SELECT Id,Email,Name FROM Contact WHERE Id IN: leadMap.keySet()]);
            for(Id i: leadMap.keySet()){
                Contact con = officers.get(i);
                System.debug(con);
                if(String.isnOtBlank(con.Email)){
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    mail.setToAddresses(new String[]{con.EMail});
                    mail.setSubject(templateId.Subject);
                    String html = templateId.HtmlValue;
                    html = html.replace('||OfficerName||',con.Name);
                    String leadsTable = '<table cellpadding="3" cellspacing="3" width="100%" align="center" border="1" style="border-collapse:collapse;">'+
                        '<tr style="font-weight:bold;"><td>Name</td><td>Phone</td><td>Starting Credit Score</td><td>Status</td><td>Enrolled On</td><td>Est. Re Pull Date</td><td>Realtor Name</td></tr>';
                    for(Lead l: leadMap.get(i)){
                        //JMA:: for each lead you can get the associated Opportunity from map <Id, Opportunity>
                        leadsTable += '<tr><td>'+l.Name+'</td>'+
                            '<td>'+l.Phone+'</td><td>'+l.Starting_Credit_Score__c+'</td><td>'+l.Status+'</td><td>'+l.Enrolled_On__c+'</td>'+
                            '<td>'+l.Est_Re_Pull_Date__c+'</td><td>'+l.Realtor_Name__c+'</td></tr>';
                    }
                    leadsTable += '</table>';
                    html = html.replace('||Leads||',leadsTable);
                    html = html.replace('null',' ');
                    mail.setHTMLBody(html);
                    mails.add(mail);
                }
            }
        }
        if(mails.size() > 0){
            //Messaging.sendEmail(mails);
        }
    }

    global void finish(Database.BatchableContext BC) {

    }
   
}

 
Hi All,

I am new to lightning and trying use file upload lightning components. 

I used exact same code which is mentioned in salesforce website
https://developer.salesforce.com/docs/component-library/bundle/lightning:fileUpload/example
just replaced recordid to my account id

But it is not working.

Please help me on this

Thanks in Advance
Hi all,

I have a custom object called "CO" and having a field called "User".
I am able to get Account ID now, but I would like to get Account Name insted.
Would someone let me know if there is a way to get Account Name from CO?

=================================
CO (CO__c)
----
Id
User (User__c) -> Contact
                            ---------
                            Id
                            Company  (Account) -> Account
                                                               ---------
                                                               Id
                                                               Name
=================================

"User"       : Lookup(Contact)
"Company": Lookup (Account)

This is what I have now.
select User__r.AccountId from CO__c where Id = 'xxxxxxx';

Thank you,
HG
  • July 10, 2018
  • Like
  • 0
Can anyone help me on getting  below data , some sample endpoint URL and response as XML.
New to Integration, learning how the parse  json and xml from response. I have one url for json( https://api.androidhive.info/contacts/) but not for xml.

Thanks in Advance.....

HttpRequest req=new HttpRequest();
req.setendpoint(' ? ');
req.setmethod('GET');
http req1=new http();
httpResponse xmlresponse=req1.send(req);

 
Hello,

I am having trouble completing a module, specifically, the second hands-on challenge. In the challenge you are asked to modify the Opportunity Pipeline report and create a Key Accounts report with a probability greater than 30%. When I go to check the challenge I am told that the report does not show records with a probability greater than 30%. I have checked the report multiple times along with recreating the report in another trailhead playground.
Has anyone experienced this problem?Trailhead Module Key Account Challenge
Dears,

Can Anyone give me a good solution !!

Example:- 

Person A and Person B Working in Same company , Person A Will not continue his job hereafter. Suddenly he leaves his job without give any information. So Person B need to handle him record as well. How it's Possible ???

1. Person A Using Different Profile .

2. Person A Records OWD is Private.

3. How person B can access that records ???


Thanks In Advance !

Regards,
Soundar P
Hi All,

Am very new to API.In my salesforce org, somebody implemented the API. I don't know whether its REST/SOAP.

Now I want to do some changes in that. Kindly let me know, where I to find the respective API details in my Org.

 

From VF Page:
<div style="float: left; width: 20%;">

<apex:outputField value="{!d.Company__c}" />

</div>

In the controller, if the Company__c is null, I want to set its value to '<div class="spacer" />' so that the div tag is rendered correctly on the page.  My output at the moment is literally <div class="spacer" />.

The goal is to have 5 static columns on the page but if one of the custom fields for the custom object is null, I just want a placeholder there in the HTML so that everything continues to line up correctly.

Hi,

How to access apex class method form process builder, I want to access apex class function by process builder but ,i am not able to access my class function.

Please suggest.

Thanks
Deepak 
Hi,

I am not aware about omni channel and where it's used.  Can you please benefit of this.


Thanks
Romash
Hi everybody,
I'm trying to render a VF Page which contains JavaScript to Generate a QR Code like so:
VF Page:
User-added image
But PDF after the renderAs is all messed up:
User-added image
Anyone knows how to render Javascript to PDF?
Hi

We have a visualforce section on all of our Opportortunity page layouts.
This section shows a particular image depending on what has been selected within the stage field.
Below is a sample of the code that we have in place.
Is it possible to split it up so that depending on which Opportunity Record Type is selected different images can be displayed against each stage?

For example if record type = X and the stage is Closed Won then show image A
If record type = Y and the Stage is closed Won then show image B

Thank you
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

></apex:image> <apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!Opportunity.stageName = 'Closed Won'}"

 ></apex:image> <apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!Opportunity.stageName = 'Closed Lost'}" 

</div>

</apex:page>

 
Hello,

I have following error:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

My usecase:
I am calling a webservice in a future handler. 

Other workaround i tried:
I tried to call the webservice without a future handler, but as i am calling in trigger it is giving me error.

Can someone please tell me any workaroud ?

thank you
Hi all,

I'm using VisualForce for an intake survey. The first part of it is relatively easy. This is the code for First Name.

<apex:inputfield value="{!Contact.FirstName}" />

However, I can't find any guidance on how to ask a yes or no question in the intake. I would want to limit it to yes or no. Not allow anything else like "working on it" or "almost."

Anyone know of a possible answer?
Hi Expert,

I have a account with oppertunities. now  i want to add GrossTotal custom field in Account and all opertunity Amount will be add in Gross total.

Please suggest.

Regards
Romesh
  


 
Hello Friends,
I am new to visualforce development,
I want to create a visualforce form in which i want a picklist field and values for picklist will be : DOC, RAR, ZIP
and a TextArea Field in which we can give comment or description
and a Save Button which will save all data of the form to the Activity Object Inside Salesforce
I have picklist field 'Filetype' with values DOC, RAR, ZIP and a TextArea Field 'Description' on Activity Object

and please do not provide any link or reference, if possible, then help me with an example,

Any help would be greatly appreciated
Thanks in Advance
Hi expert,

I have multiple country picklist in lightning compont that's is iterating in Table TR
we i choose any picklist value 'UAS' and click on save button than this picklist should be disable.

but when i change of picklist then picklist disable on selection time. but i want to disable on save button.

Please suggest
<aura:iteration items="{!v.CountryDetails}" var="item" >
<tr> 
<td class="slds-cell-wrap">
                        <lightning:select name="statusFld" label="" value="{!item.Country__c}" disabled="{!item.Country__c == 'Closed Won')}">
                            <option value="--None--">--None--</option>
                            <aura:iteration items="{!v.listCountry}" var="val">
                                <option value="{!val.value}" selected="{!val.value==item.Country__c}">{!val.key}</option>
                            </aura:iteration>
                        </lightning:select>
                    </td>
</tr>
</aura:iteration>

 
Hi I am using visualforce page to open Lightninng component in new tab:-

on opportunity object -->> button & Link (Name:-AddProduct)

add URL parameter :- 

/apex/OppProduct_VFP?oppId={!Opportunity.Id}

when user click on 'AddProduct' button then below VF page open in new tab with lightnig component:-

OppProduct_VFP:-
<apex:page controller="TestController" tabStyle="Opportunity" lightningStylesheets="true">
    <apex:includeLightning />
    <div class="slds" style="margin-top:10px;margin-left:10px;"> 
        <div id="lightning" />
    </div>
   
    <script>
    

        $Lightning.use("c:AddProductApp", function() {
            $Lightning.createComponent(
                "c:AddProduct",
                {recordId : "{!OpportunityId}"},
                "lightning",
                function(cmp) {
                   
            });
        });
    </script>
</apex:page>

i have a close button in AddProductController to close this tab but not able to closed this tab getting UNDEFINED in console log. i am not able to get TabId by this code.

 
Close : function(component, event, helper){
        var workspaceAPI = component.find("workspace"); // mentioned in component 
          workspaceAPI.isConsoleNavigation().then(function(consoleResponse) {  
              console.log('consoleResponse-->>> '+consoleResponse) // return undefined
              workspaceAPI.getFocusedTabInfo().then(function(tabResponse) {
                  console.log('tabResponse-->> '+tabResponse)// return undefined
                   var isSubtab = tabResponse.isSubtab;
                  console.log('isSubtab-->> '+isSubtab);// return undefined
              });
        });
Please suggest and let me know where i am wrong
​​​​​​​
I am using a lightning componet, whrn i click on a button then this coponent open. on this component i have a close button. when i click on this closed button page redirect to previous page, but tab not closed.

i am using below code for tab close
closeFocusedTab : function(component, event, helper) {
         var workspaceAPI = component.find("workspace");
        //alert(workspaceAPI);
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            //alert('aaaa -- '+response);
            var focusedTabId = response.tabId;
            workspaceAPI.closeTab({tabId: focusedTabId});
        })
        .catch(function(error) {
            console.log(error);
        });

    
    }

    Can you please suggest.

User-added image
Hi Expert,

I want to add attachment on record creation time in apex code, but in attachment custom code  we need record Id, but record is not created. so how achive this functionality,

Example: when we fill any exam from then we can attachemtn or document, and then save the record.

Thanks
 
Hi Expert,

i want to open a popup box that should be open when user logged In. when user  closed this then this will not reopen for this session. if user logged in again then popup should be open .

what i have done:

create a lightning component and added this on home page layout. but this popup open again and again when home page refresh. 

So can you please suggest what should i use sothat model popup should open once for current session.

Regards
Mukesh
Hi Expert,

I want to use Remote Objects in lightning component , below code is working in visualforce  pages, but now i need to implement this code in lightning component.

for example:- 
  <!-- Remote Objects definition to set accessible sObjects and fields -->
    <apex:remoteObjects >
        <apex:remoteObjectModel name="Warehouse__c" jsShorthand="Warehouse" 
            fields="Name,Id">
            <apex:remoteObjectField name="Phone__c" jsShorthand="Phone"/>
        </apex:remoteObjectModel>
    </apex:remoteObjects>

Thanks
Mukesh
Hi Expert,

In one class i have two soql:-
Example:- 
public class test(){

     List<Account> acc = [select id, name from Account Limit 40000];
     List<Contact> con = [seldect id, email from Contact Limit 15000];
}

//above queries will return limit excede error or not 

 
Hi Expert,

I want to reopen a case when any email comes from user. what i implemented:-

I creaed a workflow that execute on when agent close a case with email template taht's have a case thread id. but when customer reply this email then related case shouuld be reopen and this mail should be add in Email related list on that case.

Please suggest.

Regards
Mukesh​



  





 
Hi Expert,

How would sharing rule work in the below scenario

Suppose i create a new object called "XXXX". Now profile called "AAAA" doesn't have read, create, edit permission on it.

Q1: What would happen if I create a record of object "XXX" and share it with user which has profile "AAAA" and give him "Edit" permission on the record? Would user be able to see the record or edit the record? please qualify your answer.

Q2: Can anybody explain in what order access on record or object is granted in terms of OWD, Sharing rule, Role and profile?

Q3: If i set OWD setting as Public Read/Edit on Object "XXXX" but profile "AAAA" don't have read, create and edit permission on Object "XXXX" then the user who owns profile "AAAA" would be able to see and edit the records of object "XXXX"?

Q4: What would happen if profile "AAAA" has only Read permission on Object "XXXX" then user who owns profile "AAAA" would be able to see and edit ALL the records of object "XXXX"?

Q5: In order to work out OWD setting, at least profile must have Read permission on that particular object?

Q6: The user who is higher role in hierarchy would get owner permission on the records created by user who are lower in the roles means he can edit and delete the record as well. Is that correct?

Please share your best 

Regards
Mukesh
Hi Expert,

I have added a inline visualforce page on case page layout. Now i am able to upload files perfectlry, but now i want to add loader or spiner on file upload time. I add a spiner in visualforce page but when uploading compleatd. then this move on case Tab with files list not on same page. 
 
<apex:page standardController="Case" extensions="UploadFileController" >
<apex:form >
<style type="text/css">
.bPageBlock .detailList .dataCol {
    width: 100%;
}

.bPageBlock .detailList .dataCol {
    width: 107%;
}


dataCol.first {
    text-align: center;
    }

  .detailList td.dataCol.first.last:nth-child(1) {
    text-align: right;
    width: 50%;
}
.inner-tab {
    padding: 20px 0px;
}
  </style>
  
 
 <apex:pageMessages />
 
 <apex:actionStatus id="pageStatus">
    <apex:facet name="start">
        <apex:outputPanel >
           <img src="/img/loading32.gif" width="50" height="50" />
           
            <apex:outputLabel value="Loading..." />
        </apex:outputPanel>            
    </apex:facet>
    
    <apex:facet name="stop">
         
    
    </apex:facet>
    
</apex:actionStatus>
 
<apex:pageBlock >




<apex:pageBlockSection id="sec1" rendered="{!sec1}"> 
    <apex:commandButton id="btnUpload"  action="{!Upload}" value="Upload File"  />
   
    <br/>
     <br/>
    <apex:pageBlock title="File Links" id="rerenderId">
    
      <apex:pageBlockTable value="{!listOfFiles}" var="fl" width="100%">
           <apex:column headerValue="URL" width="50%"><apex:outputLink target="_blank" value="{!fl.URL__c}">{!fl.Url}</apex:outputLink></apex:column>
           <apex:column headerValue="Created Date" width="20%" value="{!fl.createdDate}"></apex:column> 
      </apex:pageBlockTable>
    </apex:pageBlock>
  
    
</apex:pageBlockSection>


<div class="inner-tab">
<apex:pageBlockSection id="sec2" rendered="{!sec2}">
 <apex:inputFile value="{!AttchBody}" fileName="{!AttchName}" fileSize="{!AttachSize}"/>
 
 <apex:commandButton id="btnSubmit"  action="{!SubmitAttachment}" value="Submit Attachment"/>
</apex:pageBlockSection>
 </div>


</apex:pageBlock>





</apex:form>
 
  
</apex:page>

  
public with sharing class UploadFileController {

    Public Id RecordId {get;set;}
    public Blob AttchBody {get;set;}
    public String AttchDesc {get;set;}
    public String AttchName {get;set;}
    Public Integer AttachSize {get;set;}
    Public Attachment attch {get;set;}
    public boolean attachmentBtn {get; set;}
    public boolean sec1 {get;set;}
    public boolean sec2 {get;set;} 
    public External_File_Relationship__c fileDB; 
    public External_File__c ef;
    public List<String> fileList {get;set;} 
    public String parentId; 
    Public List<External_File__c>listOfFiles {get;set;}
     
  
     public UploadFileController(ApexPages.StandardController controller) {
        parentId = ((case)controller.getRecord()).id;
        sec1 = true;
        sec2 = false;
        
        RecordId = ApexPages.CurrentPage().getParameters().get('Id');
        init();

    }
    
    
    public PageReference SubmitAttachment(){
    
      if(AttchName != '' && AttchBody != NUll ){
      
      //file that is 25Mb or less
      if(AttachSize <= 25000000 ){
          External__c  extFile = new External__c();
          extFile.Name =  AttchName;
          extFile.CaseId__c = RecordId;
          
          Insert extFile ;
          attch = new Attachment(ParentId=extFile.id,Description=AttchDesc,Name=AttchName,Body=AttchBody);
       
         try{
                insert attch;
                
                system.debug('attch  '+attch);
                AttchBody = null;
                AttchDesc = null;
                AttchName = null;
               
            }
            catch(DMLException ex){
                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
                    return null;
             
            }
            
            
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
            
            string Attid= attch.id;
            string attachmentid=Attid.substring(0,15);
            String sfdcBaseURL = URL.getSalesforceBaseUrl().toExternalForm();
            extFile.File_Public_URL__c = sfdcBaseURL+'/servlet/servlet.FileDownload?file='+attachmentid;
            update extFile;
            sec2 = false;
            sec1 = true;
            init();
          
      }
      
      }else{
      
          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, AttchName +' is too large - please choose a file that is 25Mb or less'));
      
      }
        return null;
          
      }
      
      public void init(){
           List<External_File__c> lst = [Select URL__c, CreatedDate  from  External__c where CaseId__c =: RecordId];
           listOfFiles  = lst;
      }
      
     public PageReference Upload() {
       sec1 = false;
       sec2 = true;
       
       return null;
         
    
    }

}

when i add spinner or Loding then, this move to case tab with inline visualforce page.


Please suggest, what i am doing wrong

Regards
Mukesh
 
Hi Expert,

I am using below code in my lightning componant but facing error "Jquery_File/jquery-3.3.1.min.js 404 (Not Found)" in browser console.

here "Jquery_File" is static resources name and 
 <ltng:require scripts="{!$Resource.Jquery_File + '/jquery-3.3.1.min'}" />

https://testnewdomian-dev-ed.livepreview.salesforce-communities.com/sfsites/c/resource/1535093740000/Jquery_File/jquery-3.3.1.min.js 404 (Not Found)

Thanks
Mukesh

 
Hi Expert,

I want to create  New Event  on Calander object from community user. But When i click on calander date then popbox show message :-

"Looks like there's a problem.
Oops...you don't have the necessary privileges to create this record. See your administrator for help."

User-added image

Please suggest

Regards
Mukesh
Hi Expert,

I am using customer service template, when i move builder and component anf try to search "Case Comments Publisher"  component in component list, but not able to find.

 User-added image

Please help


Regards
​Mukesh
Hi Expert,

I want to create a report and dashboad that's have filter   case escalation, SLAs, and Key Peformance Indicators.

but i am not able to justify SLAs, and Key Peformance Indicators on caes report and dashboad, 

what field that's using for SLAs, and Key Peformance Indicators on case report,

Please confirm.

Thanks

 
Hi,

I am implementing Open CTI Lightning Demo Adapter in salesforce by reference of https://developer.salesforce.com/page/Lightning_Open_CTI

and installed from :- https://login.salesforce.com/packaging/installPackage.apexp?p0=04t41000000bSXh

but facing error 

User-added image

Thanks
Mukesh


 
Hi,

I want to show reports on dashboard for communtiy users, report is currect fetaching related user data but dashboard showing All reports  

User-added image

User-added image



Please suggest
Hi Expert,

I want no convert this custom button into Lightning. Please suggest

User-added image 
Thanks
Mukesh
Hi, 

I am using window.load() in visualforce page, but in lightning readiness report , window.load() does not support in Lightning. Message is  below:- 

"JavaScript included in this page uses window. methods. Included JavaScript uses window. methods for navigation, which are not supported in Lightning Experience."

Can you please suggest , what substitute i can use instead of window.load() for Lightning;

Thanks
Mukesh
 
Hi Expert

I want to update Lead object field by child object of Lead, but i am not able to get relation.

Please suggesy
I am creating Lightning componant. but not able to save this componant.

User-added image

Thanks
Mukesh
Hi Expert,

I want to create some demo on marketing cloud  journey builder. Can any one share about how to acces journey builder in markeing cloud.

Thanks
Mukesh
Hi Expert,

I need to create an application for me to send SMS directly from Salesforce. Please suggest.

User-added image
Hi Expert,

I am using a test class for coverage 75% code, but few things are not covered. Can any one suggest what is going wrong.

this my test Class: --
@isTest
public class TestProfessorSelectCourse {
    @isTest static void ProfessorCourse(){
       
        
        Professor__c prof = new Professor__c(Name ='JP',Email__c='jp@gmail.com');
        insert prof;
        
        Class__c cls = new Class__c(name='12G', Class_Teacher__c = prof.id);
        insert cls;
        
        Course__c cors = new Course__c(Professor__c=prof.id,Class__c =cls.id, name='Ruby', Start_Date__c= Date.today() , End_date__c= Date.newInstance(2017,03,20));
       	//Professor__c prof = new Professor__c(Name ='JP');
        //cors.Professor__c = prof.Name;
        insert cors;
    }
}

and below is my main class


User-added image

Thanks 
Mukesh
I am using a lightning componet, whrn i click on a button then this coponent open. on this component i have a close button. when i click on this closed button page redirect to previous page, but tab not closed.

i am using below code for tab close
closeFocusedTab : function(component, event, helper) {
         var workspaceAPI = component.find("workspace");
        //alert(workspaceAPI);
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            //alert('aaaa -- '+response);
            var focusedTabId = response.tabId;
            workspaceAPI.closeTab({tabId: focusedTabId});
        })
        .catch(function(error) {
            console.log(error);
        });

    
    }

    Can you please suggest.

User-added image
how to create Save and New Button in Lightning Component
hi
Please help me 
Hi,

I have below apex class which i am not able to cover in test class.
public class createdoc
{  
public PageReference CreateDocument()
    {
                   product pr = [select id, Limited_Company_App_Form__c from product where id=:opp.product__c];
            docsetting sett = new docsetting (pr.Limited_Company_App_Form__c );                         
            string body= sett.Calldoc(opportunityId);   
              
            if(sett.AttachmentId != null)
            {
                Opp.Attachment_App_Form__c = sett.AttachmentId;
                update opp;
                           } 
               
        
        return null;
    
 }       
    }

 

Hello,
I used the monthbetween method to calculate the number of months between two dates and to create, from the contract, a task if the number of months between the end of the contract and today is equal to 3 (batch).
The problem is that I have a contract whose end date s 17/07/2019. at each batch launch I have a task that is created (as it does not take into account the day j).
I have to follow a specific hierarchy to insert response from external app in salesforce objects. The hierarchy is like- Projects --> tasklists --> tasks. For storing task's project-id, I have to check if the same project already exists or not. If not,create one before creating task. How can I make a comparision between existing records and external app response?
Field NameField TypeDescription
Previous OwnerLookup (User)The prior sales rep assigned to this Account
New OwnerLookup (User)The new sales rep assigned to this Account
Previous TerritoryLookup (Territory__c)The matching Territory__c record for the prior zip code
New TerritoryLookup (Territory__c)The matching Territory__c record for the new zip code
AccountMaster-Detail (Account)The related Account record
Changed ByLookup (User)The user who changed the BillingPostalCode
how to transfer records from one batch class to another batch class
global class LoanOfficerBatch implements Database.Batchable<sObject> {
    public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, ConvertedOpportunityId, Name, Phone, Starting_Credit_Score__c, ' 
                          +  'Status, Enrolled_On__c, Est_Re_Pull_Date__c, Realtor_Name__c ' 
                          +   ' FROM Lead'; /*JMA:: add  ConvertedOpportunityId field*/ 
    public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1];

    global Database.QueryLocator start(Database.BatchableContext bc) {

        query += ' WHERE CreatedDate >= LAST_MONTH AND CreatedDate <= THIS_MONTH AND Loan_Officer_1a__c != null';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, list<Lead> allLeads) {
        
        //JMA:: Create a map of <Id, Opportunity>
        Map<Id,List<Opportunity>> OpptyMap = new Map<Id,List<Opportunity>>();
        //JMA:: Query Opportunities by using Lead.ConvertedOpportunityId. You need to first create a set of Id from Lead.ConvertedOpportunityId
        //JMA:: populate the map <Id, Opportunity>
        
        Map<Id,List<Lead>> leadMap = new Map<Id,List<Lead>>();
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMEssage>();
        if(allLeads != null && allLeads.size() > 0){
            for(Lead l: allLeads){
                if(!leadMap.containsKey(l.Loan_Officer_1a__c)){
                    leadMap.put(l.Loan_Officer_1a__c, new List<lead>());
                }
                leadMap.get(l.Loan_Officer_1a__c).add(l);
            }
        }
        if(leadMap.keySet().size() > 0){
            Map<Id,Contact> officers = new Map<Id,Contact>([SELECT Id,Email,Name FROM Contact WHERE Id IN: leadMap.keySet()]);
            for(Id i: leadMap.keySet()){
                Contact con = officers.get(i);
                System.debug(con);
                if(String.isnOtBlank(con.Email)){
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    mail.setToAddresses(new String[]{con.EMail});
                    mail.setSubject(templateId.Subject);
                    String html = templateId.HtmlValue;
                    html = html.replace('||OfficerName||',con.Name);
                    String leadsTable = '<table cellpadding="3" cellspacing="3" width="100%" align="center" border="1" style="border-collapse:collapse;">'+
                        '<tr style="font-weight:bold;"><td>Name</td><td>Phone</td><td>Starting Credit Score</td><td>Status</td><td>Enrolled On</td><td>Est. Re Pull Date</td><td>Realtor Name</td></tr>';
                    for(Lead l: leadMap.get(i)){
                        //JMA:: for each lead you can get the associated Opportunity from map <Id, Opportunity>
                        leadsTable += '<tr><td>'+l.Name+'</td>'+
                            '<td>'+l.Phone+'</td><td>'+l.Starting_Credit_Score__c+'</td><td>'+l.Status+'</td><td>'+l.Enrolled_On__c+'</td>'+
                            '<td>'+l.Est_Re_Pull_Date__c+'</td><td>'+l.Realtor_Name__c+'</td></tr>';
                    }
                    leadsTable += '</table>';
                    html = html.replace('||Leads||',leadsTable);
                    html = html.replace('null',' ');
                    mail.setHTMLBody(html);
                    mails.add(mail);
                }
            }
        }
        if(mails.size() > 0){
            //Messaging.sendEmail(mails);
        }
    }

    global void finish(Database.BatchableContext BC) {

    }
   
}

 
Hi all,

I want to display the contact in the Opportunity which are related to the same account in the salesforce lighting.

Can anyone help over here.

Thanks in advance,
raju.
Someone before me had written a process that is fired when a custom object is created/edited and that process would create cases. The custom object record gets created when an email is received in their group mail. But the issue is I can't find any process, workflow rule, flow or custom apex classes or triggers that creates the custom object. There are apex classes/triggers from managed packages but the contents are hidden. How do I detect if some automation process created those records? The reason I'm trying to find what's creating the records is because sometimes the custom object records corresponding cases dont get created.
The standard value set for Contract.Status causes an error 'Field:null is not a picklist'.   I am guessing this because the current structure for the standard value set doesn't contain a value for the StatusCode, which is required for every Contract.Status value.  Has anyone solved this issue?  Is it on the roadmap to be addressed?  Can we do anything other than put it into the .forceignore?
 
Here is a similar question: 
https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F93A000000HTp1SAG&fId=0D53A00003NmQ4cSAF
I am working on a managed package and I want to do some customization. I want to create a lookup filter. My understanding in a managed package a lookup filter cannot be created.How can I do this ?Is there any workaround for this?
I've created a simple trigger on contact to check a box after delete.  When I activate the trigger I can no longer delete a contact.  Error: "There's a problem saving this record. You might not have permission to edit it, or it might have been deleted or archived. Contact your administrator for help."
Trigger:
trigger trgDeletedContact on Contact (after delete) {
    for (Contact c: trigger.old){
        c.IsDeleted__c = TRUE;
    }
}

Thanks in advance!
Hi Developers,
I came across a issue that apex cannot process xlxs, xls but didn't get clear explaination.
Can anyone explain why we cannot process xlsx,xls but can only process CSV and other format?
Thanks

I'm trying to get totals of opportunity amounts using "this week", "last week", "n weeks ago" in new custom fields, and then roll up the totals in summary reports. However, I get errors saying these don't exist, either with the underscore or without. How can I use them in calculated fields?

 

A typical use case would be:

 

IF(CloseDate = Last_Week,Amount,0)    or  IF(CloseDate = 3 weeks ago,Amount,0)

 

For me, TODAY() and Now() work, but not other literals. 

 

Guidance, please...