• RJ12
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 10
    Replies
I have an HTML email template with merge fields (from Lead object) in both subject and body.

I'm sending an email using the HTML template through apex, I'm able to populate merge fields in the email template Body but not on Subject.
 
EmailTemplate et = [SELECT Id,Subject, Body,HtmlValue FROM EmailTemplate WHERE DeveloperName ='Email_Template_Name'];
string toAddress='';
            
List<Lead> lstUpLead=new List<Lead>([Select id,Street from lead where id IN: lstTriggerNew]);
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();

  for(Lead objLeadUpdate : lstUpLead){

    toAddress=lstLead.Email;
    String[] sendingTo = new String[]{toAddress}; 
    semail.setToAddresses(sendingTo);
    semail.setSubject(et.subject);
    string plainBody=et.HtmlValue;
    plainBody=objLeadUpdate.Street!=null?plainBody.replace('{!Lead.Street}',objLeadUpdate.Street):plainBody.replace('{!Lead.Street}','....');
    semail.setHtmlBody(plainBody);
    semail.setTargetObjectId(objLeadUpdate.id);
    semail.setWhatId(objLeadUpdate.id);
    semail.setSaveAsActivity(false);
    semail.setTemplateId(et.Id);

}


Merge fields used in the HTML email template:
  • Subject:  {!Lead.FirstName}
  • Body:  {!Lead.Street}
Any help is highly appreciated.
  • December 06, 2019
  • Like
  • 0

Can we update a converted lead record when a field is updated in the Account record? (The account record was created from the same converted lead record)

 

  • June 14, 2019
  • Like
  • 0

Can you help me to write a trigger that captures the value of a number field in child records and calculates the total sum in the Parent record?​​​​​​​

​​​​​​​Example:
Parent: Account
Field: Total_Value__c

​​​​​​​Child: Contact
Field: Value__c

Parent record can have multiple child records. How can I sum up all the values in value__c from child records and save in Total_Value__c  in parent record using trigger?

  • May 14, 2019
  • Like
  • 0

I have a table in VF and I have to make it dynamic.
User-added image

We are using the standard controller for the Visualforce page. All input fields (24 fields) in the table were mapped to a custom object. Whenever we fill the info and click on save button, all values from the table will save in a record.

Now I have to make this table dynamic. All the cell mapping should be the same as before.
1. Initially, I have to display 1 row and an 'Add' button should be at the bottom.
2. When the user clicks on the 'Add' button it should display another row.
3. From the second row, we need to display 'Delete' button/ link which allows the user to delete the row.
4. We should restrict user not to create more than 4rows (because we already mapped 24 cells to 24 fields in the custom object).

Can anyone help me with this?

  • November 28, 2018
  • Like
  • 0
I wrote a batch apex that invokes a Flow interview. Somehow my Test class is not covering execute method. Can anyone help me out?
Batch Apex:
global class Lead_remind implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Date d = Date.today();
        String query = 'SELECT Id, OwnerId, Reminder_date__c, Rev_Date__c, Status FROM Lead where Status=\'Qualify\' AND Reminder_date__c=:d';
  return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Lead> scope)
    {
        for(Lead l : scope)
        {
            Map<String, Object> params = new Map<String, Object>();
            params.put('LId',l.Id);
            params.put('LeadOwnerId',l.OwnerId);
            params.put('BusinessDay_3',l.Reminder_date__c);
            params.put('BusinessDay_4',l.Rev_Date__c);
            Flow.Interview.Lead_Flow lFlow = new Flow.Interview.Lead_Flow(params);
            lFlow.start();       
        }
        update scope;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }

}

Test Class:
 
@isTest
private class Lead_remind_Test {
static testMethod void testMethod1() 
    {
            Lead L= new Lead();
            L.OwnerId = '0055A00000A6s5pLAQ';
            L.LastName ='Lead Name';
            L.Company = 'Lead Company';
            L.Status = 'New'; 
            L.LeadSource = 'Social';
            L.Phone = '7364859473';
            insert L;
        
           L.Reminder_date__c = Date.today();
           L.Status = 'Qualify';
	   update L;
        
        Test.startTest();
            Lead_remind obj = new Lead_remind();
            DataBase.executeBatch(obj); 
        Test.stopTest();
    }
}

Reminder_date__c, Rev_Date__c are 'Date' fields. These fields will be populated by a workflow when Lead status is 'Qualify'.
  • November 01, 2018
  • Like
  • 0

I have a 'Task' and 'Email Alert' workflow actions. Is there a way to execute those workflow actions using Batch Apex?

Can anyone help me out on this?

  • October 30, 2018
  • Like
  • 0
I wrote a test class for batch apex but somehow getting 38% code coverage only. can anyone help me where I'm doing wrong?

I'm running a scheduler everyday morning to trigger Task, an Email alert from Flows when LMDate__c = today.
X1st_Business__c, LMDate  = formula field of type 'date '(Calculated based on last modified date)
X3rd_Business__c, X4th_Business__c are 'date' fields populated automatically using workflow when Lead status moved from 'Preparing' to 'Working'.

Batch Apex:
global class Batchable_Lead implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Date d = Date.today();
        String query = 'SELECT Id, X1st_Business__c, X3rd_Business__c, X4th_Business__c, Status, LMDate__c FROM Lead where X1st_Business__c!=null AND X3rd_Business__c!=null AND X4th_Business__c!=null AND Status=\'Working\' AND LMDate__c=:d';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Lead> scope)
    {
        for(Lead l : scope)
        {
            Map<String, Object> params = new Map<String, Object>();
            params.put('LId',l.Id);
            Flow.Interview.Lead_Flows calcFlow = new Flow.Interview.Lead_Flows(params);
            calcFlow.start();       
        }
        update scope;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }

}

Test Class:
 
@isTest
private class Batchable_Lead_Test {
static testMethod void testMethod1() 
    {
            Lead L= new Lead();
        	L.OwnerId = '0055A00000A6s7sQAB';
                L.LastName ='Lead Test Name';
                L.Company = 'Test Company';
                L.Status = 'Scheduling';
                L.LeadSource = 'Social';
        	L.Phone = '7364859473';
        	L.Bankruptcy__c = TRUE;
       	 	L.Street = '1234 abcd';
       	 	L.City = 'xxxxx';
       	 	L.State = 'yyyyy';
                L.PostalCode = '98765';
                L.Country = 'United States';
            insert L;
        
        Test.startTest();

            Batchable_Lead_Untouch obj = new Batchable_Lead_Untouch();
            DataBase.executeBatch(obj); 
            
        Test.stopTest();
    }
}

Unable to cover 'global void execute' class.
  • October 26, 2018
  • Like
  • 0

If a record is in Lead Status 'Working' and untouched(didn't edit) for 3 business days, I have to send a Task and Email to Lead owner and Manager (user lookup in Lead).

I tried with time-based workflow and process builder but it is not working properly. I believe this is can be done using Scheduler.

1. Can anyone help me how to achieve this using Apex Scheduler?

2. I have created Task and Email Alert in workflow actions. Is it possible to trigger them with scheduler Apex?

  • October 25, 2018
  • Like
  • 0
We are using a batch class to create users in Salesforce. Is there any way to assign the particular permission set to users upon creation?

Suggestions are highly appreciated.
  • October 04, 2018
  • Like
  • 0
I have a requirement that users send List Emails frequently to contacts in Salesforce Lightning. Is there any way to capture the most recent List Email sent date and get that date in the corresponding contact record's custom field?

For instance, List_Email_1 is sent to 10 contacts on 8/10/2018 and List_Email_2 is sent to another set of 10 contacts on 8/12/2018.
I have to show the List_Email_1 sent date(8/10/2018) on its corresponding 10 contact records and List_Email_2 sent date(8/12/2018) on its corresponding 10 contact records.
 
Help me if there is a solution.
  • August 20, 2018
  • Like
  • 0
I wrote batch apex and it sends email using Flows. (I wrote all the email functionality in Flows and called that flow in my batch class)
global class BatchDocumentsUpdate implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Date d = Date.today();
        String query = 'SELECT Id, Contact__c, Expiry_Date__c, Reminder_date__c, ContactStatus__c FROM Documents__c where Contact__c!=null AND Expiry_Date__c!=null AND ContactStatus__c=\'On Assignment\' AND Reminder_date__c=:d';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Documents__c> scope)
    {
        for(Documents__c a : scope)
        {
            Map<String, Object> params = new Map<String, Object>();
            params.put('CLId',a.Id);
            Flow.Interview.EmailReminder calcFlow = new Flow.Interview.EmailReminder(params);
			calcFlow.start();
            a.Reminder_date__c = Date.today()+1;          
        }
        update scope;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}
'CLId' is a variable in the flow.
'Email Reminder' is the flow name.

I wrote a test class for this. But I'm unable to cover the EXECUTE method.
Documents__c is a child to Contact object.
@isTest
private class BatchDocumentsUpdate_Test {
    static testMethod void testMethod1(){
            Account acc = new Account();
            acc.Name ='Acc Name';
  			insert acc;
        
        	Contact con = new Contact();
       		con.AccountId = acc.id;
       		con.LastName = 'Con Name';
            con.Work_Status__c = 'On Assignment';
       		insert con;
        
        	Documents__c cl= new Documents__c();
            cl.Contact__c = con.id;
            cl.Expiry_Date__c = System.today() + 10;
            cl.ContactStatus__c = 'On Assignment';
            insert cl;
        
        Test.startTest();
            BatchDocumentsUpdate obj = new BatchDocumentsUpdate();
            DataBase.executeBatch(obj); 
        Test.stopTest();
    }
}
Can anyone help me in getting the Execute method covered?

Thanks

 
  • August 15, 2018
  • Like
  • 0
<apex:page showHeader="false" sidebar="false" controller="OppDetailsCntlr" standardStylesheets="false" >
<apex:stylesheet value="{!URLFOR($Resource.file, 'file/css/box.css')}"/>
  
  <!--This content is displayed in abox -->
  
  <div class="Header">{!$Label.Standard_Header}</div>
  <div class="scrollClass">
  <apex:repeat value="{!OppDetails}" var="details" >      
      <table class="contentTable">
        <tbody>
            <tr>
                <td >{!if(details.typeTitle!='',details.typeTitle,'Classification')}:</td>
                <td>{!details.reqType}</td>
            </tr>
            <tr>
                <td >{!if(details.cornersTitle!='',details.cornersTitle,'Open Corners')}:</td>
                <td>{!details.Corners}</td><br/>
            </tr>
        </tbody>
       </table>
  </apex:repeat> 
  </div>
  
  <!-- Until this part, content is displayed in a box -->
  
</apex:page>


I wrote the above code. I created a box using CSS, in which content will be displayed in the box with a header '{!$Label.Standard_Header}'.  

I'm trying to hide the entire box including header label if there is no content available (Content is dynamic, it will be populated based on opportunity records). Can anyone help me on this?

  • May 08, 2018
  • Like
  • 0
I have 2 child objects related to Lead and I have another 2 child objects with same fields(Same Label, API names) related to contact object. 

How to map/copy fields of 2 child objects related to the Lead object to 2 child objects related to Contact object upon lead conversion?

User-added image
  • May 04, 2018
  • Like
  • 0

I have a parent object A and two child objects X, Y. Both X, Y have lookup relation to object A.

I'm looking for a trigger to delete related records in both X, Y objects when a parent record in object A is deleted.

  • May 04, 2018
  • Like
  • 0
My client is using Gsuit and they want to send emails from Salesforce with 'To address' as their Gmail id.

For this, I activated 'Google Apps' and enabled 'Send through External Email Services'. Now they can send email from Salesforce with their Gmail Id and can track sent emails in both Gmail and Salesforce. 
But the problem is the email that sent out from Salesforce is not picking up email signatures that are already in Gmail.

Is there any way to pick the Gmail Signatures?
  • February 09, 2018
  • Like
  • 0

I'm new to SF Developement. I'm trying to get Account Name in the Opportunity for some scenario.
I'm getting Null value when I'm trying this code
 

for(Opportunity opp:trigger.New){
                if(opp.Quote_Category__c != 'Choose One'){
                    oppJobList.add(opp.AccountId.Name);
                }
            }
 

Help me on this. Thank you.

  • January 17, 2018
  • Like
  • 0

I have designed a Lightning Component (VF page in the front) for integration. Where I used two buttons, one for generating Access Code, one for generating Access Token. I want to combine 2 buttons into 1. If I click the button, Access code and Access Token must be generated.

My code looks like this:

<button class="slds-button slds-button_brand" data-url="{!'https://XYZ.com/oauth/authorize?client_id='+ v.CUSTOMOBJECT.Client_Id__c+'&amp;scope='+v.CUSTOMOBJECT.scope__c+'&amp;redirect_uri='+v.CUSTOMOBJECT.Redirect_Url__c+'&amp;state=SF'}" onclick="{!c.getAccessCode}">Generate Access Code</button>

<button class="slds-button slds-button_brand" onclick="{!c.getAccessToken}">Generate Access Token</button>
  • January 12, 2018
  • Like
  • 0
I'm trying to create a new Slack channel whenever a new Opportunity is created in Salesforce. For Instance, if I create an Opportunity with the name "Test Record" then a new Slack channel with name "#Test Record" must be created in the Slack.
Can anyone help me on this?

Any documentation/ references/ resources will be highly appreciated.
  • January 08, 2018
  • Like
  • 0

I'm trying to write a trigger to update a field in Parent record when Child record is created or updated.

Parent Object: Opportunity
Custom Field in Parent Object: Signed_by__c

Child Object: Invoice__c
Custom Field in Child object: Signed_by__c

Whenever the child record is saved (Inserted/updated), the value in 'Signed_by__c' field in child record must be copied to 'Signed_by__c' field in the parent record.

  • December 26, 2017
  • Like
  • 0
I need help in integrating Quickbooks with Salesforce using API. 
  • December 18, 2017
  • Like
  • 0

I have a table in VF and I have to make it dynamic.
User-added image

We are using the standard controller for the Visualforce page. All input fields (24 fields) in the table were mapped to a custom object. Whenever we fill the info and click on save button, all values from the table will save in a record.

Now I have to make this table dynamic. All the cell mapping should be the same as before.
1. Initially, I have to display 1 row and an 'Add' button should be at the bottom.
2. When the user clicks on the 'Add' button it should display another row.
3. From the second row, we need to display 'Delete' button/ link which allows the user to delete the row.
4. We should restrict user not to create more than 4rows (because we already mapped 24 cells to 24 fields in the custom object).

Can anyone help me with this?

  • November 28, 2018
  • Like
  • 0
I wrote a batch apex that invokes a Flow interview. Somehow my Test class is not covering execute method. Can anyone help me out?
Batch Apex:
global class Lead_remind implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Date d = Date.today();
        String query = 'SELECT Id, OwnerId, Reminder_date__c, Rev_Date__c, Status FROM Lead where Status=\'Qualify\' AND Reminder_date__c=:d';
  return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Lead> scope)
    {
        for(Lead l : scope)
        {
            Map<String, Object> params = new Map<String, Object>();
            params.put('LId',l.Id);
            params.put('LeadOwnerId',l.OwnerId);
            params.put('BusinessDay_3',l.Reminder_date__c);
            params.put('BusinessDay_4',l.Rev_Date__c);
            Flow.Interview.Lead_Flow lFlow = new Flow.Interview.Lead_Flow(params);
            lFlow.start();       
        }
        update scope;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }

}

Test Class:
 
@isTest
private class Lead_remind_Test {
static testMethod void testMethod1() 
    {
            Lead L= new Lead();
            L.OwnerId = '0055A00000A6s5pLAQ';
            L.LastName ='Lead Name';
            L.Company = 'Lead Company';
            L.Status = 'New'; 
            L.LeadSource = 'Social';
            L.Phone = '7364859473';
            insert L;
        
           L.Reminder_date__c = Date.today();
           L.Status = 'Qualify';
	   update L;
        
        Test.startTest();
            Lead_remind obj = new Lead_remind();
            DataBase.executeBatch(obj); 
        Test.stopTest();
    }
}

Reminder_date__c, Rev_Date__c are 'Date' fields. These fields will be populated by a workflow when Lead status is 'Qualify'.
  • November 01, 2018
  • Like
  • 0
<apex:page showHeader="false" sidebar="false" controller="OppDetailsCntlr" standardStylesheets="false" >
<apex:stylesheet value="{!URLFOR($Resource.file, 'file/css/box.css')}"/>
  
  <!--This content is displayed in abox -->
  
  <div class="Header">{!$Label.Standard_Header}</div>
  <div class="scrollClass">
  <apex:repeat value="{!OppDetails}" var="details" >      
      <table class="contentTable">
        <tbody>
            <tr>
                <td >{!if(details.typeTitle!='',details.typeTitle,'Classification')}:</td>
                <td>{!details.reqType}</td>
            </tr>
            <tr>
                <td >{!if(details.cornersTitle!='',details.cornersTitle,'Open Corners')}:</td>
                <td>{!details.Corners}</td><br/>
            </tr>
        </tbody>
       </table>
  </apex:repeat> 
  </div>
  
  <!-- Until this part, content is displayed in a box -->
  
</apex:page>


I wrote the above code. I created a box using CSS, in which content will be displayed in the box with a header '{!$Label.Standard_Header}'.  

I'm trying to hide the entire box including header label if there is no content available (Content is dynamic, it will be populated based on opportunity records). Can anyone help me on this?

  • May 08, 2018
  • Like
  • 0

I have designed a Lightning Component (VF page in the front) for integration. Where I used two buttons, one for generating Access Code, one for generating Access Token. I want to combine 2 buttons into 1. If I click the button, Access code and Access Token must be generated.

My code looks like this:

<button class="slds-button slds-button_brand" data-url="{!'https://XYZ.com/oauth/authorize?client_id='+ v.CUSTOMOBJECT.Client_Id__c+'&amp;scope='+v.CUSTOMOBJECT.scope__c+'&amp;redirect_uri='+v.CUSTOMOBJECT.Redirect_Url__c+'&amp;state=SF'}" onclick="{!c.getAccessCode}">Generate Access Code</button>

<button class="slds-button slds-button_brand" onclick="{!c.getAccessToken}">Generate Access Token</button>
  • January 12, 2018
  • Like
  • 0
I need help to create a task based on Opportunity Field.
 
Let's say I have a picklist field in Opportunity called 'Type' with Values A, B.

 If value 'A' is selected then you must check for Synced Quote in that Opportunity related list. In the synced Quote, if the Status field is 'Rejected' then we must create 2 Tasks in the Opportunity Record with the subject line 'Task Subject 1' and 'Task Subject 2'.

I have a custom picklist field in the Task called 'Task Value' with values X, Y. 

So Tasks must be created as
Task 1:
Subject Line: Task Subject 1
Task Value: X

Task 2:
Subject Line: Task Subject 2
Task Value: Y

These 2 tasks must be displayed on the opportunity related list 'Open Activities'.
 
  • November 22, 2017
  • Like
  • 0