• Prabha
  • NEWBIE
  • 328 Points
  • Member since 2012

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 101
    Replies
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>

Hello,

I have a junction object between and contact and a custom object like below

Custom_object_X__C
- Id

Jucntion__c
-Id
- LookUpToJCustom_object_X__c
-LookUpToContact__c

Contact
-Id

On the custom object there is a related list of Jucntion__c, so in page layout it is like below

Record of Custom_object_X
- Name
- Picklist X
- ......
- ....
>Related list 1
>Related list to display Jucntion (This related list will also display the contact it is related to in one of the column)

Use case:
I want a custom button to select few records of junction and send an email to contacts. also if possible to select the emil template of choice

Like below, we are abe to select the quote, simillarly i want to able to select the records on junction object and send email to Quote
User-added image 

thanky you for sugetion
 

Hi All,
 I'm using a custom apex controller. I have some master/detail relationships between some custom objects (Client --> Booking)
I'm trying to create a new child record on the Booking object (dependent child object). 
How do I specify the reference to the parent object when creating this new Booking record. 
I have a soql query that returns the existing clients which are then displayed in a selectList. 
I want to be able to associate the selected record in that select list as the master record associated with this new booking record. 
I'm hoping I'm not confusing the crap out of everyone. 
Here is my schema:
User-added image

Also as this is a custom controller, do I have to assign the Last Modified Date, Created By field values explicitly I can create a new booking record? I'm assuming nothing comes for free here? I'm not even sure what I'm suppose to put in those for those either. My primary hiccup is how do I assign the Availability and Client fields? Does that have to equal the Client.Name from the client object and Availability.Name from Availability Object?
 
<apex:page standardController="Booking__c" extensions="testing10" docType="html-5.0">
    <apex:form >
    	<apex:pageBlock >
        	<apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                <apex:outputLabel >Booking Date</apex:outputLabel>
                <apex:inputfield value="{!Records.Start_Date_Time__c}">
                <apex:actionSupport action="{!UpdateSitter}" event="onchange" reRender="D1"/>   
           		</apex:inputfield>
	        </apex:pageBlockSectionItem>                 
                </apex:pageBlockSection>
            
            <apex:pageBlockSection columns="1" id="D1">
                 <apex:outputLabel rendered="{!FlagH}">Baby Sitters</apex:outputLabel>
                 <apex:selectList value="{!SelectedSitter}" size="1" rendered="{!FlagH}"> <!--var holding selected item-->
                 <apex:selectOptions value="{!RecordOption}" rendered="{!FlagH}"/> 
                  </apex:selectList>
              
                  <apex:outputLabel rendered="{!FlagH}">Clients</apex:outputLabel>
                  <apex:selectList value="{!SelectedClient}" size="1" rendered="{!FlagH}"> <!--var holding selected item-->
                  <apex:selectOptions value="{!ClientOption}" rendered="{!FlagH}"/> 
                  </apex:selectList>
                
                  <apex:outputLabel rendered="{!FlagH}">Number of Hours Needed</apex:outputLabel>
                  <apex:input type="number" id="hoursI" value="{!hours}" html-min="2" html-max="8" rendered="{!FlagH}"/      
                
              <apex:pageBlockTable value="{!Sdate}" var="sd" rendered="{!FlagH}">
                    <apex:column value="{!sd}"/>
                   <apex:column value="{!Record.End_Date_Time__c}"/>
             </apex:pageBlockTable>
                
              </apex:pageBlockSection>
              <apex:pageBlockButtons location="bottom">
	          <apex:commandButton action="{!save}" value="Save"/>
	          </apex:pageBlockButtons>
        
        </apex:pageBlock>
    </apex:form>
</apex:page>

public class testing10 {
   public Booking__c Records{get;set;}
    public Boolean FlagH{get;set;}
    public Datetime DTime {get;set;}
    public List<SelectOption> RecordOption{get;set;} //stores the babysitters names in the picklist
    public Date PickDate{get;set;}
    public String Sdate{get;set;}
    public String SelectedSitter{get;set;}
    public String SelectedClient{get;set;}
    public List<SelectOption> ClientOption{get;set;} 
    public Integer hours{get;set;} 
  
 
    public PageReference UpdateSitter(){
  
      RecordOption = new List<SelectOption>();  //list to hold my babysitters returned 
      ClientOption = new List<SelectOption>(); //list to hold clients
        
        try{
          Dtime = Records.Start_Date_Time__c; //retrive datetime input 
          PickDate= DTime.date(); //convert datetime to date type
          Sdate = String.valueOf(PickDate);
          SelectedClient ='';
            
          RecordOption.add(new SelectOption('', '----Noness----'));
          ClientOption.add(new SelectOption('', '----Select Client----'));
            
          List<Availability__c> tempval = new List<Availability__c>([SELECT Id, Name, BabySitter__r.name, BabySitter__r.First_Name__c from Availability__c WHERE Date_Available__c =: PickDate and Booked__c=FALSE]);
          List<Client__c> tempClient = new List<Client__c>([SELECT Id, Name, First_Name__c, Last_Name__c from Client__c]);
            FlagH=false; //hides rendered block until returned date has an associated value (babysitters)
            if(tempval.size() > 0){  //babysitters are found
                FlagH=true;
                for(Availability__c a : tempval){
                    RecordOption.add(new SelectOption(a.Id, a.BabySitter__r.First_Name__c));
                }
               
                if (tempClient.size() > 0){
                      for(Client__c c : tempClient){
                    	ClientOption.add(new SelectOption(c.Id, c.Name));
                	}
				}
                
                //calculate end date/time
                Records.End_Date_Time__c = Records.Start_Date_Time__c + (hours/24);
                
                //assign client to new booking??????
                Records.Client__c = SelectedClient;
                
                //assign Availability/sitter?????????
                Records.Availability__r.Name = SelectedSitter;
              
            }
           
       
        }catch(Exception e){
            
        }    
       
        return null;
    }
    
    public PageReference save(){
        insert Records;
        //need to save booking with selected babysitter, selected date
        //update availability to booked (boolean)
        //return to listview page (parent page)
        return null;
    }
    public testing10(ApexPages.StandardController controller){
        FlagH = false;
        SelectedClient ='';
        SelectedSitter = '';
        Records = (Booking__c)controller.getRecord();
        
        
    }
    public testing10(){}
}

 
I created an Apex Trigger, a few custom fields, and a couple validation rules so that I can check that a contact role is assigned to an opportunity. It actually allows me to check that multiple contacts are assigned at different stages of the sales cycle. It works great in my sandbox but I can't deploy the Apex Before Trigger because it doesn't reach the code coverage thresholds. I'm a point-and-click admin that happened to pull this together based on articles I found. Can someone help me write the test so that I can pass the code coverage test and deploy this?

Here is the Apex before trigger:
trigger updatecontactrolecount on Opportunity (before insert, before update)
{

Boolean isPrimary;
Integer iCount;

Map<String, Opportunity> oppty_con = new Map<String, Opportunity>();//check if the contact role is needed and add it to the oppty_con map
for (Integer i = 0; i < Trigger.new.size(); i++)
{
    oppty_con.put(Trigger.new[i].id,
    Trigger.new[i]);
}
isPrimary = False;
for (List<OpportunityContactRole> oppcntctrle :[select OpportunityId from OpportunityContactRole where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId in :oppty_con.keySet())])
{
if (oppcntctrle .Size() >0)
{
isPrimary = True;
}
}
iCount = 0;
for (List<OpportunityContactRole> oppcntctrle2 : [select OpportunityId from OpportunityContactRole where (OpportunityContactRole.OpportunityId in :oppty_con.keySet())])//Query for Contact Roles
{
if (oppcntctrle2 .Size()>0)
{
iCount= oppcntctrle2 .Size();
}
}
for (Opportunity Oppty : system.trigger.new) //Check if roles exist in the map or contact role isn't required
{
Oppty.Number_of_Contacts_Roles_Assigned__c = iCount;
Oppty.Primary_Contact_Assigned__c =isPrimary;
}
}

Thank you!
Nick
I'd like to create a role for 2 of my reps to be able to view, add, and edit notes for all of my accounts.  How can i go about doing that?
Hai,
My requirment is when i click on list page that means i created output link for id click that id it will navigate to record view page but it is not displaying values to the record view page
i write vf page and code
vf page
=----------------------
<apex:page controller="list_controller1" sidebar="false" tabStyle="Employee_Information__c">
<apex:form >
<apex:pageBlock title="Employee List">
<apex:pageBlockSection title="Employee Information Displaying ">
<apex:pageBlockTable value="{!empdetails}" var="e">
<apex:column headerValue="ID">
<apex:outputLink value="https://c.ap2.visual.force.com/apex/Record_detail_Vf_Page?id = e.id">{!e.id}</apex:outputLink>
</apex:column>
<apex:column value="{!e.First_Name__c}"/>
<apex:column value="{!e.Middle_Name__c}"/>
<apex:column value="{!e.Last_Name__c}"/>
<apex:column value="{!e.Date_of_Birth__c}"/>
<apex:column value="{!e.Father_Husband_Name__c}"/>
<apex:column value="{!e.Marital_Status__c}"/>
</apex:pageBlockTable>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

controller
------------------------------
public class list_controller1
{

    public Employee_Information__c[] getEmpdetails()
    {
        empdetails = Database.query(query);
        return empdetails;
    }

    Employee_Information__c[] empdetails;
    string query = 'select id,First_Name__c,Middle_Name__c,Last_Name__c,Date_of_Birth__c,Father_Husband_Name__c,Marital_Status__c from Employee_Information__c';

    

}

please help me any one
User-added imageUser-added image

in the first image i click the id link it will navigate to secong image but here values are not displaying for fields .
please help me
any one
User-added image

Hi,
I have an object 'Address' and I made a visual for for adding an address on Account.When i introduce a filter the list with the address is updated. Can I make this page to work in salesforce1 ?
Hi Guys,

i have three page visulaforce wizard with a custom controller. I tried to override New button with the forst oage in th ewizard but coukdnot find the visulaforce page in the drop down list. can any one suggest a way to override new button with custom controller visualforce page or any other alternative to implement the wizard?


 
  • April 09, 2015
  • Like
  • 0
I have a Lookup field on a Contact record called Spouse__c. It enables me to add a link to another Contact to the Contact record. We manually reciprocate so both Contacts have their related spouse.
I also have a Deceased__c checkbox.  I am trying to indicate on Spouse 1 if Spouse 2 has the Deceased checkbox checked.

IF(Spouse__r.Deceased__c,'',
TEXT(SpouseDeceased)
)

But this doesn't work.

Hello!

 

I have a custom button that creates a pdf and emails it to a client from a custom object.  I now want to have the button only work when the record has a status of approved.  I have a status field Status__c, with multiple values, Approved being the one I want to have the fire off of.  I am not sure how to accomplish this.  The button is referencing a visual force page, and I am not sure if this condition needs to be set on the VF page or in the button (on click java script).  Any suggestions? 

Hi

 

Is the following possible in pageblock table?

 

I have a map structure: map<string, list<string>> ,

the values could be,

for example:

key: fruits:

values: orange, apple, grape

key: Vehicle:

values: car, motorbike, trolley, lorry, truck

key: shape:

values: round, square.

 

Now I want to show that in a pagblock table where keys as column headers and values as column values! 

 

I was only able to get that with map<string, string>. 

 

 
       <apex:pageBlockTable value="{!a1}" var="ms">
           <apex:repeat value="{!a1}" var="r"> 
                   <apex:column headerValue="{!r}"> 
                       <apex:repeat value="{!a1[r]}" var="r1"> 
                         {!r1}
                       </apex:repeat>
                   </apex:column>
           </apex:repeat>
       </apex:pageBlockTable>

 Please enlighten me on this. 

Can it be done as the way I want it to be?

 

 

Prabhan

  • August 11, 2013
  • Like
  • 0

Hi Gurus,

 

I have been working on a requirement which includes FTP integration. 

 

The requirement is that we need to send all the Accounts with their child records in csv to an FTP server. And Accounts alone are morethan 100,000 records.

 

We started working trembling, we used apex classes for each 5000 records as the heap is getting heavier for a single class. Now there are multiple chunks coming out of that apex class files.

 

We tested it with a button in VF page and class. And we used the same to send a mail. Successful. Then we tested the same with apex scheduler as the requirement demands that entire hierarchy is to be sent every by 8:00 PM. 

 

Now we got stuck at the part of integrating it with FTP. 

 

We have been searching a lot, and some older posts said that "we can not ftp out any files directly from cloud".

 

And also this .. http://www.chiragmehta.info/chirag/2010/03/22/salesforce-ftp-integration-data-loader-web-service-http/

 

........................................................

 

All we are trying to do is to send the file to an FTP. Is there anybody out there who did such kind of integration, please send some workaround.

 

  • October 04, 2012
  • Like
  • 0

Hi,

 

I am trying to populate value in one field based on the picklist selection in different field of the samae object.

 

exactly like "stage" and "probability" in opportunity..

 

please check the code and tell me why it is not working only in apex:pageBlockTable.

I searched the boards and followed some solution but its not coming,

 

my VF is:

<apex:page standardController="contact" extensions="practice4">

  <script type="text/javascript">
   function populatefield()
    {
     var ex = document.getElementById('{!$Component.form.block.sec.firstfieldID}').value;
     if(ex=="one")
      document.getElementById('{!$Component.form.block.sec.secondfieldID}').value = '1';
     else
      document.getElementById('{!$Component.form.block.sec.secondfieldID}').value = '';
      
     var ex = document.getElementById('{!$Component.form.block.sec.table.firstfieldID1}').value;
          alert(ex);
     if(ex=="one")
      document.getElementById('{!$Component.form.block.sec.table.secondfieldID1}').value = '1';
    }
  </script>
  
<apex:form id="form" >
<apex:pageBlock id="block" >
<apex:pageBlockSection id="sec" >

 <apex:inputField id="firstfieldID" value="{!contact.third__c}" onchange="populatefield();" />
 <apex:inputField value="{!contact.second__c}" id="secondfieldID" />                   

 <apex:pageBlockTable id="table" value="{!section1}" var="allGNG">
  <apex:column headervalue="pick" width="15%" >
  <apex:inputField id="firstfieldID1" value="{!allGNG.third__c}" onchange="populatefield();" >
  </apex:inputField>
  </apex:column>  
  <apex:column headerValue="value">
  <apex:inputField value="{!allGNG.second__c}" id="secondfieldID1" />                   
  </apex:column>

 </apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

my controller is  

public class practice4 {

    public practice4(ApexPages.StandardController controller) {

    }
    public contact[] section1 = new contact[0];
    
     Public List<contact> getsection1()
    {
     section1= [SELECT third__c, second__c from contact];
     return section1;
    }


}

what I saw is "document.getElementById" is getting the values from pageblocksection, but not from pageblocktable.

 

Is there any other way...?!?

 

Thanks

Prabhan

 

 

  • August 01, 2012
  • Like
  • 0
I am doing this for so many objects , but i have observed that three objects in my org is not having the option "List View Button Layout" itself. Rest of the objects are having this option. All are custom objects btw Can anyone tell me what might be the reason for this. PS: I am in lightning environment only.
Hello Everyone,
I am facing one issue related to LWC. I am using record edit form to create case record and I have some Lightning Input Fields on my form. The issue is there are two fields which are dependent on one picklist field. This picklist field has two values 'Physical'and 'Digital'.If user selects physical the other two fields become mandatory and if they select Digital both the fields are not mandat. If user selects Physical then both the fields become mandatory and at the same time without saving the record if user change back the picklist value to Digital both the values become non manadat but the error' complete this field' still persists . The error and the red border do not hide. Do we have any workaround on the same. 

User-added image


User-added image
public class QuoteHW {
 public CustomOpportunity__c opp{get;set;}
    public CustomQuote__c quo {get;set;}
    public Id oppid{get;set;}
    public CustomOpportunitylineitem__c oppli{get;set;}
    public List<CustomOpportunitylineitem__c> opplilist{get;set;}
    public CustomQuotelineitem__c quoli{get;set;}
    
    public QuoteHW()
        
        
    {   
     ApexPages.Pagereference pageref = ApexPages.currentPage();
         oppid = pageRef.getParameters().get('Id');
      
      
        opp = new CustomOpportunity__c();
        opp = [Select Name, AccountName__c,Quantity__c, ContactName__c, Amount__c from CustomOpportunity__c where Id=: oppid ];
        opplilist = [SELECT Name , ActualPrice__c,DiscountValue__c, CustomOpportunity__c, CustomProduct__c, Quantity__c, UnitPrice__c from CustomOpportunitylineitem__c where CustomOpportunity__c=: opp.Id];
        
        
    }
    public pagereference Save()
       {
         quo = new CustomQuote__c();
         quo.AccountName__c= opp.AccountName__c;
         quo.CustomOpportunity__c = oppid;
         quo.Quantity__c= opp.Quantity__c;
         quo.ContactName__c= opp.ContactName__c;
         quo.Amount__c= opp.Amount__c;
         quo.Name = opp.Name;
         insert quo;
         
         for( CustomOpportunitylineitem__c a : opplilist)
         {
            quoli = new CustomQuotelineitem__c();
            quoli.ActualPrice__c= a.ActualPrice__c;
            quoli.DiscountValue__c= a.DiscountValue__c;
            quoli.CustomProduct__c= a.CustomProduct__c;
            quoli.Quantity__c = a.Quantity__c;
            quoli.UnitPrice__c = a.UnitPrice__c ;
            quoli.CustomOpportunitylineitem__c = a.Id;
            quoli.CustomOpportunity__c = a.CustomOpportunity__c ;
            quoli.CustomQuote__c = quo.Id;
            quoli.name = a.name;
            insert quoli;
          }
            
          
         pagereference pr = new pagereference('/' + quo.Id);
         return pr;
         
         
         
                    
       
       }
    

}IN SOQL showing an error ,Can someone please me out form this code.<apex:page controller="QuoteHW"  sidebar="false" >
 <apex:form >
  <apex:sectionHeader title="New Quote"/>
   <apex:pageBlock title="Edit Quote">
   
   <apex:pageBlockButtons >
    <apex:commandButton value="Save"  action="{!Save}"/>
    <apex:commandButton value="Cancel" />
   </apex:pageBlockButtons>
   
    <apex:pageBlockSection title="Quote">
     <apex:outputField label="Account Name" value="{!opp.AccountName__c}"/>
     <apex:outputField label="Quantity" value="{!opp.Quantity__c}"/>
     <apex:outputField label="Contact Name" value="{!opp.ContactName__c}"/>
     <apex:outputField label="Amount" value="{!opp.Amount__c}"/>
     </apex:pageBlockSection>
     <apex:pageBlockSection title="Product Details">
     
     <apex:pageBLockTable value="{!opplilist}" var="opl" >
     
      <apex:column value="{!opp.AccountName__c}" headerValue="Account Name"/>
      <apex:column value="{!opl.CustomOpportunity__c}" headerValue="Opportunity Name"/>
      
      <apex:column value="{!opl.Name}" headerValue="Opportunity Line Item Name"/>
      
      <apex:column headerValue="Actual Price"> 
       <apex:inputField value="{!opl.ActualPrice__c}" />
       </apex:column>
      
      <apex:column headervalue="Discount Value" >
      <apex:inputField value="{!opl.DiscountValue__c}" />
      </apex:column>
        <apex:column headervalue="Product">
      <apex:inputField value="{!opl.CustomProduct__c}" />
      </apex:column>
      
      
      <apex:column headerValue="Quantity">
       <apex:inputField value="{!opl.Quantity__c}" />
      </apex:column>
      <apex:column headervalue="Unit Price">
      <apex:inputField value="{!opl.UnitPrice__c}" />
      </apex:column>
     
      
      
     </apex:pageBLockTable>
    
    </apex:pageBlockSection>
   </apex:pageBlock>
 </apex:form>
</apex:page>


 
Create a field called 'Latest Opportunity Amount' on Account.and then Auto Populate the above field  with the Newley created Opportunities’ Amount. How to do this.
  • March 14, 2023
  • Like
  • 0
I have a batch class , it got stucked after processing some batch jobs.. it is working in some orgs but in some org its getting stucked, not throwing any error message. in the batch class I am using Tooling api and get the data and storing it. In finish method I am calling next batch class.
Any help will be highly appreciated.
hightlights class is getting stucked, In finish method i am calling next batch
I have a scenario where I want to make an Apex Trigger so that when a record is inserted or updated when I click on save, the trigger is triggered.
The object that the trigger will be started will be in a custom object and updated in another custom object.

I created a lookup field in object 2, in this case the PropertyInformation__c object relating to object 1, Properties__c.


Objects:
  • Object 1: Properties__c
Fields:
  • PropertyType__c      - data type: picklist with values ​​(Apartment, Commercial, Land, Home, Office)
  • PropertyForSaleOrRent__c      - data type: picklist with values ​​(Rent, Sell)
  • NumberOfRooms__c - number data type
Object 2: PropertyInformation__c

Lookup Field: ResponsibleBroker__c
 
  • Fields to be updated:
  • PropertyType__c
  • PropertyForSaleOrRent__c
  • NumberOfRooms__c

How could I be creating the apex trigger to be able to update the fields in object 2?
Controller Code:
public with sharing class ExportTemplateController {
    
    public String xlsHeader{
        get{
            String strHeader = '';
            strHeader += '<?xml version="1.0"?>';
            strHeader += '<?mso-application progid="Excel.Sheet"?>';
            return strHeader;
        }
    }
    
    public String filterNameData{
        get{
            String selectedFilterId = this.controller.getFilterId();
            return selectedFilterId;
        }
    }
    
    ApexPages.StandardSetController controller;    
    public ExportCSVController(ApexPages.StandardSetController controller) {
        
        this.controller = controller;   
        if (controller.getResultSize() < 2000 ) {
            controller.setPageSize(controller.getResultSize());
        } else {
            controller.setPageSize(2000);
        }
   }

Test Class (so far I've researched and written)
 
@isTest
private static void ExportTemplateTest() {

    //Try insert a list of accounts to use Account Controller

    List<Account> testAccs = new List<Account>();
    for (Integer i = 0; i < 200; i++) {
        Account a = new Account(Name='TestAccount' + i);
        testAccs.add(a);
    }
    insert testAccs;
    
    Test.startTest();
    PageReference pageRef = Page.OpenAccountPage;
    Test.setCurrentPage(pageRef);
    ApexPages.StandardSetController stdSetController = new 
    ApexPages.StandardSetController(testAccs);
    stdSetController.setSelected(testAccs);
    ExportCSVController ext = new ExportCSVController(stdSetController);
    System.assertEquals(200, 200);
    Test.stopTest();
}

The code coverage is now 30%. Please help me with writing methods to cover public String xlsHeader & public String filterNameData.

The Controller was written by another Developer that is no longer working in my company. I'm taking his task now. 

As I've researched, Get is a Read-only variable. How do we call/invoke/access it in Test Class?

Thank you so much.
Hi, I have written below batch class how can I write test class for this

code:-
global class DeleteLeads_Batch implements Database.Batchable<sObject> {  
    Id rtid = RecordTypeUtil.getRecordTypeIdByDevName('Lead','Digital_Marketing');
    String query = 'select id, Status, recordtype.name from Lead where recordTypeid = rtid AND (LastModifiedDate > LAST_N_DAYS:180 OR Status like \'%Closed%\'';
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC,List<Lead> leadList){    
        delete leadList;
    }
    global void finish(Database.BatchableContext BC){
        System.debug('Job Finished');
    }
}

Thanks,
Mayuri

Hi all,
I am not able to clear this challenge. Please advise. https://trailhead.salesforce.com/content/learn/projects/workshop_mgmt/workshop_mgmt_flow

User-added imageUser-added imageUser-added image

global class SendNPSbutton {
    @AuraEnabled
    public static void sendNPSEmail(Id cId)
    {
        EmailTemplate emiailTemp = new EmailTemplate();
        String htmlBody; 
        String plainBody;
        String subject;
        List<String> sendTo = new List<String>();
        contact cc = [select id from contact limit 1];
        
        Closing__c cpps = [SELECT Id,RecordTypeId,RecordType.Name,Seller_Email__c,Buyer_Email__c,Owner.FirstName,
                           Buyer_Account__c,Seller_Account__c,Seller_Account__r.Name,Appointment__r.Name
                           FROM Closing__c where Id=: cId LIMIT 1];
        
        if(cpps.Id != null)
        {
            if(cpps.RecordType.Name =='Listing Team'){
                sendTo.add(cpps.Seller_Email__c);
                emiailTemp = [SELECT Id, Name,Subject, DeveloperName,HtmlValue, Body FROM EmailTemplate where DeveloperName = 'NPS_Survey_npsSeller'];
                subject = emiailTemp.Subject;
                htmlBody= emiailTemp.HtmlValue;
                htmlBody = htmlBody.replace('{!Closing__c.Seller_Account__c}', cpps.Seller_Account__r.name);
                htmlBody = htmlBody.replace('{!Closing__c.OwnerFirstName}', cpps.Owner.FirstName);
                plainBody = emiailTemp.Body;
                plainBody = plainBody.replace('{!Closing__c.Seller_Account__c}', cpps.Seller_Account__c);
                plainBody = plainBody.replace('{!Closing__c.OwnerFirstName}', cpps.Owner.FirstName);
            }else{
                sendTo.add(cpps.Buyer_Email__c);
                emiailTemp = [SELECT Id, Name,Subject, DeveloperName,HtmlValue, Body FROM EmailTemplate where DeveloperName = 'NPS_Survey_nps'];
                subject = emiailTemp.Subject;
                htmlBody= emiailTemp.HtmlValue;
                htmlBody = htmlBody.replace('{!Closing__c.Buyer_Account__c}', cpps.Appointment__r.Name);
                htmlBody = htmlBody.replace('{!Closing__c.OwnerFirstName}', cpps.Owner.FirstName);
                plainBody = emiailTemp.Body;
                plainBody = plainBody.replace('{!Closing__c.Seller_Account__c}', cpps.Seller_Account__c);
                plainBody = plainBody.replace('{!Closing__c.OwnerFirstName}', cpps.Owner.FirstName);
            }
            // process the merge fields
            // String subject = emailTemplate.Subject;
            //  subject = subject.replace('{!Contact.FirstName}', c.FirstName);

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setTemplateId(emiailTemp.Id);
            List<String> ccTo = new List<String>();
            ccTo.add('xyz@gomail.com');
            mail.setCcAddresses(ccTo);
            mail.setReplyTo('xyz@gomail.com');
            mail.setSenderDisplayName('XYZ');
            mail.setTargetObjectId(cc.id);
            mail.setTreatTargetObjectAsRecipient(false);
            mail.setWhatId(cpps.Id);
            mail.setToAddresses(sendTo);     
            mail.setBccSender(false);
            mail.setUseSignature(false);
            mail.setHtmlBody(htmlBody);
            mail.setSubject(subject);
            mail.setPlainTextBody(plainBody);
            mail.setSaveAsActivity(false);  
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
           
        }
    }
    
}

 

TEST Class:

@istest(SeeAllData=true)

public class SendNPSButton_test{
    
    static testmethod void testvalidate(){
        List<String> sendTo = new List<String>();
        Account acc = new Account();
        acc.Name = 'Name test';
        insert acc;
        Closing__c cl = new Closing__c();
        //cl.RecordTypeId=Schema.SObjectType.Closing__c.getRecordTypeInfosByName().get('Buying Team').getRecordTypeId();
        cl.Buyer_Email__c = 'ravi.7293@gmail.com';
        cl.Seller_Email__c ='ravi.7293@gmail.com';
        cl.Seller_Account__c = acc.Id;
        insert cl;
       EmailTemplate emiailTemp = [SELECT Id, Name,Subject, DeveloperName,HtmlValue, Body FROM EmailTemplate where DeveloperName = 'NPS_Survey_npsSeller'];
        /*Closing__c cpps = [SELECT Id,RecordTypeId,RecordType.Name,Seller_Email__c,Buyer_Email__c,Owner.FirstName,
                           Buyer_Account__c,Seller_Account__c,Seller_Account__r.Name,Appointment__r.Name
                           FROM Closing__c where Id=: cl.Id LIMIT 1];*/
        system.debug('cl>>: '+ cl);
        Test.startTest();
       // Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         //   mail.setTemplateId(emiailTemp.Id);
        //mail.setToAddresses(sendTo);
        //Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        system.debug('cl11>>: '+ cl.Seller_Email__c);
        system.debug('cID>>: '+ cl.ID);
        SendNPSbutton.sendNPSEmail(cl.Id);
        //Integer emailInvocations = Limits.getEmailInvocations();
        Test.stopTest();
        //system.assertEquals(1, emailInvocations, 'An email should be sent');
        
    }
}

 

 

when I click on the button to redecte me to another visualforce page I get a blank page it's not working for me but for others, it's work I use google chrome as navigator .

it works for other members, and am working on Classique version 
I have a validation rule in effect where a field needs to be checked off in order to save the record.  It acts as an acknowledgment.  After it is checked and the record saved, I would like the checkbox to uncheck itself.  Is there a trigger I can implement that would uncheck the box after completion, however not interfere with the validation rule that enforces the checkbox to be checked when saving.  Appreciate your help with this!

Thanks,
Mike
I have created the lightning component and want to display it on VF page and render as PDF. For this, I have created a Lightning Dependency App and added it to VF page using $Lightning.createComponent(String type, Object attributes, String locator, function callback). 
I have followed steps mentioned in the following documentation: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_visualforce.htm
But nothing is displayed in PDF.

Here is the code:
App:
​<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:AccountSnapshotComponent"/>
</aura:application>

VF Page:
<apex:page renderAs="pdf" standardStylesheets="false">
    <apex:includeLightning />
    <div id="lightning" />
    <script>
        $Lightning.use("c:AccountSnapshotApp", function() {
            $Lightning.createComponent("c:AccountSnapshotComponent",
                                       { label : "Press Me!" },
                                       "lightning",
                                       function(cmp) {
                                           // do some stuff
                                       });
        });
    
    </script>
</apex:page>

 Please help to display data in PDF format.