• Michael Clarke 16
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 9
    Replies
I am on the record page for Plant__c object and wanting to customised the list for the child Plant_In_Zone__c object with a vf page.

How do I build the custom list controller? The below code won't save/compile - unexpected token PIZs line 3 (for a start).
public class listPIZCustomController {

    public ApexPages.StandardSetController PIZs
        get{
            if(PIZs==null){
                PIZs = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, Plant__c, Layer__c, Name, Plant_Name__c, Common_Name__c, Zone__c, Zone_Name__c FROM Plant_In_Zone__c 
                    WHERE Plant__c=:apexPages.currentPage().getParameters().get('Id')]));
            }
            return PIZs;
        }
    
    	set;
   }

    public List<Plant_In_Zone__c> getPIZs() {
        return (List<Plant_In_Zone__c>)PIZs.getRecords();
    }
}

 
I have photos in Google Photos and have whitelisted https://photos.google.com and https://photos.app.goo.gl.

On the object Plant_Image__c I have a field Photo_URL__c that contains the URL of the photo that is shared in Google Photos.

I am building a vf page to add to a lightning record page for the Plant Image object.

How can I get the image in Google Photos to show on the vf page?
I have tried iFrame with image and image on its own.
<apex:page standardcontroller="Plant_Image__c" showHeader="False">
    <apex:image alt="{!Plant_Image__c.Plant_Name__c}" height="400" url="{!Plant_Image__c.Photo_URL__c}"/><br/>
</apex:page>

User-added image
I have bulkified my Auto Lead Convert apex class and written a trigger.
It works fine for one Lead updated via the UI.
However when I create Leads in the Open Execute Anaopnymous Window I get an error.

Trigger:
trigger LeadTrigger on Lead (before insert, after insert, before update, after update, before delete, after delete) 
{
    If(trigger.isAfter && (trigger.isInsert || trigger.isUpdate))
    {

        List<Id> LeadIds = new List<Id>();
		Integer i = 0, l = 0;
        system.debug('Trigger size: '+trigger.new.size());
        
        for(Lead thisLead:trigger.new) //loop through all inserted or updated leads
        {
            l = l + 1;
            system.debug('Check that Lead is not converted and meets criteria.');
            if(!thisLead.IsConverted && thisLead.LeadSource == 'Web' && thisLead.Rating == 'Hot') //if current lead matches criteria
            {
                system.debug('Lead '+i+': '+thisLead.Id+' is not converted and meets criteria.');
                LeadIds.add(thisLead.Id); //add Lead to LeadIds list
                i = i + 1;
	        }
	        else
    	    {
            	system.debug('Lead');
        	}
        }
        system.debug(l+' Leads inserted or updated.');

        if(LeadIds.size()>0)
        {
            AutoMassConvertLeads.LeadAssign(LeadIds);
        }
        system.debug(i+' Leads converted.');
    }
}
Bulkified Auto Convert Lead Apex Class:
Public class AutoMassConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        system.debug('Select the Status Label for a converted Lead');
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        system.debug('Create Database.LeadConvert List');
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
            system.debug('Create Database.LeadConvert for current Lead');
        	Database.LeadConvert Leadconvert = new Database.LeadConvert();
            system.debug('Set Lead Id for Lead Conversion for current Lead');
        	Leadconvert.setLeadId(currentlead);                
            system.debug('Change status of the Lead to converted for current Lead');
        	Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
            //Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
            system.debug('Add current Lead Conversion to Lead Conversion List');
            MassLeadconvert.add(Leadconvert);
        }
        Boolean LCR_Success = TRUE;
        Integer Count_LCR_Success = 0;
        Integer Count_LCR_Failures = 0;
        
        if (!MassLeadconvert.isEmpty()) {
            system.debug('Convert all Leads and store in LeadConvert Result List lcr');
            List<Database.LeadConvertResult> lcrs = Database.convertLead(MassLeadconvert);
            system.debug('Confirm Success of Lead conversion');
            for(Database.LeadConvertResult lcr:lcrs){
                if(lcr.isSuccess()){
                    Count_LCR_Success = Count_LCR_Success + 1;
                }
                else
                {
                    Count_LCR_Failures = Count_LCR_Failures + 1;
                }
            }
        	system.debug('Lead Conversion process complete');
        	system.debug(Count_LCR_Success+' successes');
        	system.debug(Count_LCR_Failures+' failures');
        }
    }
}
Execute Anonymous Window:
Lead newLead = new Lead();
    List<Lead> newLeads = new List<Lead>();
        
    newLead.FirstName = 'TestFirstName11';
    newLead.LastName = 'TestLastName11';
    newLead.Company = 'TestCompany11';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Warm';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test11@testdwr.com.zz';
    system.debug('Lead Company 11: '+newLead.Company);
    newLeads.add(newLead);
    system.debug('newLead11 added to newLeads');
    system.debug(newLeads[0]);
    
    newLead.FirstName = 'TestFirstName22';
    newLead.LastName = 'TestLastName22';
    newLead.Company = 'TestCompany22';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Hot';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test22@testdwr.com.zz';
    newLead.Rating = 'Hot';
    newLeads.add(newLead);
    system.debug('newLead22 added to newLeads');
    system.debug(newLeads[1]);

    newLead.FirstName = 'TestFirstName33';
    newLead.LastName = 'TestLastName33';
    newLead.Company = 'TestCompany33';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Hot';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test33@testdwr.com.zz';
    newLead.Rating = 'Hot';
    newLeads.add(newLead);
    system.debug('newLead33 added to newLeads');
    system.debug(newLeads[2]);
	
insert newLeads;
Log:
Error Log
Your help solving this would be very much appreciated.
Hi, I am new to salesforce code.
I am building an Auto Convert Lead process when LeadSource = 'Web' and Rating = 'Hot'.
I have written the Apex Code (I will bulikfy it when it works and I fully understand the process) and a Test Class which runs successfully.
I have a Process Bulder that kicks it off. (passes through LeadIds = Lead.Id)
User-added imageApex Code:
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        system.debug('1');
        Database.LeadConvert leadConvert = new Database.LeadConvert();
        system.debug('2');
        leadConvert.setLeadId(LeadIds[0]);

        system.debug('3');
        LeadStatus LeadStat= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];

        system.debug('4');
        leadConvert.setConvertedStatus(LeadStat.MasterLabel);
        //Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to   create an opportunity from Lead Conversion 

        system.debug('5');
        Database.LeadConvertResult lcr = Database.ConvertLead(leadConvert);
        system.debug('6');
        System.assert(lcr.isSuccess());
        system.debug('7');
    }
}

Test Class:
@isTest
private class AutoConvertLeadsTest {

    @isTest static void testLeadConversion() {
        Lead Ld = new Lead();
        Ld.FirstName = 'TestFirstName';
        Ld.LastName = 'TestLastName';
        Ld.Company = 'TestCompany';
        Ld.LeadSource = 'Web';
        Ld.Rating = 'Warm';
        Ld.Status = 'Open - Not Contacted';
        Ld.Email = 'test@testdwr.com.zz';
        system.debug('a');
        insert Ld;
        system.debug('b');
        Ld.Rating = 'Hot';
        update Ld;
        system.debug('c');

    }
}

When I edit the LeadSource = 'Web' and Rating = 'Hot' on the UI it kicks off the Process and then Apex code.
I get the following error:
Review the errors on this page.
We can't save this record because the “Auto Convert Lead” process failed. Give your Salesforce admin these details. An Apex error occurred: System.DmlException: ConvertLead failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?: [] Error ID: 839700365-14885 (-1370628323)


I am mystified what the source of the error is.
Hoping you can help me.
What does this mean?
Salesforce Error ID: 1194933230-286794 (-991972232)

Can you also point me to documentation?
Thanks
Created my first VF Page today.
How do I get rid of the white space that takes up half of the component in a Lightning page?

User-added image
I want to add a custom Highlights component to a Lightning Record Page. I have never created a Visualforce Page for adding to a Lightning canvas.
I may be way off the mark but gave it a go.
Any tips to get this working would be great!

<apex:page standardController="Opportunity">
    
    <apex:pageBlock title="Opportunity Summary">
        <apex:pageBlockTable value="{!Opportunity}" var="opp">
            <apex:column title="Customer(s)"/>
              <apex:column title="Guarantor(s)"/>
              <apex:column title="Lender"/>
              <apex:column title="Lender ID"/>
              <apex:column title="Broker"/>
              <apex:column title="Broker Code"/>
              <apex:column title="Loan Amount"/>
              <apex:column title="Close Date"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp1">
              <apex:column value="{!opp1.Applicant_1__c}"/>
              <apex:column title="Guarantor 1"/>
            <apex:column value="{!opp1.Lender__c}"/>
              <apex:column value="{!opp1.Account.Lender_ID__c}"/> <!-- Get customer field on Account object -->
              <apex:column value="{!opp1.User.FullName}"/> <!-- Get name of Opportunity Owner -->
              <apex:column value="{!opp1.User.AFG_Code__c}"/> <!-- Get custom field on User object -->
              <apex:column value="{!opp1.Amount}"/>
              <apex:column value="{!opp1.CloseDate}"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp2">
              <apex:column value="{!opp2.Applicant_2__c}"/>
              <apex:column title="Guarantor 2"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

Current Error Message: Invalid field USER for sObject Opportunity.
I am sure there are more errors.
Hi, there are many posts showing how to create formula fields for images and refer to the image in the Documents tab. In Lightning we have Files tab and not Documents tab. How do you get the image URL?
Hi, I am checking the challenge for Create Sharing Rules and receive the below error message. I have not changed anything on the default user Edna Frank that came with the Developer Org. I have set Access Mapping User:Acount = Case: Account. Please help.
User-added image
Hi, I have built my first vf page and controller extension and it works fine in Sandbox.
How do I create a Test class for this?

Visualforce Page:
<apex:page standardController="Case" extensions="Case_ListOppSplits_Controller" lightningStylesheets="true">
    <apex:pageBlock>
    	<apex:pageBlockTable value="{!Opportunity_Splits}" var="oppSplit">
            <apex:column value="{!oppSplit.Name}"/>
            <apex:column value="{!oppSplit.Split_Loan_Amount__c}"/>
            <apex:column value="{!oppSplit.Rate_Type__c}"/>
            <apex:column value="{!oppSplit.Repayment_Type__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Controller Extension Class:
public class Case_ListOppSplits_Controller {

    public Case myCase;
    
    public Case_ListOppSplits_Controller(ApexPages.StandardController stdController){
        this.myCase = (Case)stdController.getRecord();

    }

//initialise setController  and return  a list of records
    public list<Opportunity_Split__c> getOpportunity_Splits(){
        Case currentCase = [SELECT Id, Subject, Opportunity__c FROM Case WHERE Id =: ApexPages.currentPage().getParameters().get('id')];
        List<Opportunity_Split__c> OppSplit = [SELECT Id, Name, Opportunity__c, Loan_Purpose__c, Loan_Type__c, Loan_Usage__c, Rate_Type__c, Repayment_Type__c, Split_Loan_Amount__c
                     FROM Opportunity_Split__c
                     WHERE Opportunity__c =: currentCase.Opportunity__c];
        return OppSplit;
    }
    
}

​​​​​​​
I have bulkified my Auto Lead Convert apex class and written a trigger.
It works fine for one Lead updated via the UI.
However when I create Leads in the Open Execute Anaopnymous Window I get an error.

Trigger:
trigger LeadTrigger on Lead (before insert, after insert, before update, after update, before delete, after delete) 
{
    If(trigger.isAfter && (trigger.isInsert || trigger.isUpdate))
    {

        List<Id> LeadIds = new List<Id>();
		Integer i = 0, l = 0;
        system.debug('Trigger size: '+trigger.new.size());
        
        for(Lead thisLead:trigger.new) //loop through all inserted or updated leads
        {
            l = l + 1;
            system.debug('Check that Lead is not converted and meets criteria.');
            if(!thisLead.IsConverted && thisLead.LeadSource == 'Web' && thisLead.Rating == 'Hot') //if current lead matches criteria
            {
                system.debug('Lead '+i+': '+thisLead.Id+' is not converted and meets criteria.');
                LeadIds.add(thisLead.Id); //add Lead to LeadIds list
                i = i + 1;
	        }
	        else
    	    {
            	system.debug('Lead');
        	}
        }
        system.debug(l+' Leads inserted or updated.');

        if(LeadIds.size()>0)
        {
            AutoMassConvertLeads.LeadAssign(LeadIds);
        }
        system.debug(i+' Leads converted.');
    }
}
Bulkified Auto Convert Lead Apex Class:
Public class AutoMassConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        system.debug('Select the Status Label for a converted Lead');
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        system.debug('Create Database.LeadConvert List');
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
            system.debug('Create Database.LeadConvert for current Lead');
        	Database.LeadConvert Leadconvert = new Database.LeadConvert();
            system.debug('Set Lead Id for Lead Conversion for current Lead');
        	Leadconvert.setLeadId(currentlead);                
            system.debug('Change status of the Lead to converted for current Lead');
        	Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
            //Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
            system.debug('Add current Lead Conversion to Lead Conversion List');
            MassLeadconvert.add(Leadconvert);
        }
        Boolean LCR_Success = TRUE;
        Integer Count_LCR_Success = 0;
        Integer Count_LCR_Failures = 0;
        
        if (!MassLeadconvert.isEmpty()) {
            system.debug('Convert all Leads and store in LeadConvert Result List lcr');
            List<Database.LeadConvertResult> lcrs = Database.convertLead(MassLeadconvert);
            system.debug('Confirm Success of Lead conversion');
            for(Database.LeadConvertResult lcr:lcrs){
                if(lcr.isSuccess()){
                    Count_LCR_Success = Count_LCR_Success + 1;
                }
                else
                {
                    Count_LCR_Failures = Count_LCR_Failures + 1;
                }
            }
        	system.debug('Lead Conversion process complete');
        	system.debug(Count_LCR_Success+' successes');
        	system.debug(Count_LCR_Failures+' failures');
        }
    }
}
Execute Anonymous Window:
Lead newLead = new Lead();
    List<Lead> newLeads = new List<Lead>();
        
    newLead.FirstName = 'TestFirstName11';
    newLead.LastName = 'TestLastName11';
    newLead.Company = 'TestCompany11';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Warm';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test11@testdwr.com.zz';
    system.debug('Lead Company 11: '+newLead.Company);
    newLeads.add(newLead);
    system.debug('newLead11 added to newLeads');
    system.debug(newLeads[0]);
    
    newLead.FirstName = 'TestFirstName22';
    newLead.LastName = 'TestLastName22';
    newLead.Company = 'TestCompany22';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Hot';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test22@testdwr.com.zz';
    newLead.Rating = 'Hot';
    newLeads.add(newLead);
    system.debug('newLead22 added to newLeads');
    system.debug(newLeads[1]);

    newLead.FirstName = 'TestFirstName33';
    newLead.LastName = 'TestLastName33';
    newLead.Company = 'TestCompany33';
    newLead.LeadSource = 'Web';
    newLead.Rating = 'Hot';
    newLead.Status = 'Open - Not Contacted';
    newLead.Email = 'test33@testdwr.com.zz';
    newLead.Rating = 'Hot';
    newLeads.add(newLead);
    system.debug('newLead33 added to newLeads');
    system.debug(newLeads[2]);
	
insert newLeads;
Log:
Error Log
Your help solving this would be very much appreciated.
Hi, I am new to salesforce code.
I am building an Auto Convert Lead process when LeadSource = 'Web' and Rating = 'Hot'.
I have written the Apex Code (I will bulikfy it when it works and I fully understand the process) and a Test Class which runs successfully.
I have a Process Bulder that kicks it off. (passes through LeadIds = Lead.Id)
User-added imageApex Code:
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        system.debug('1');
        Database.LeadConvert leadConvert = new Database.LeadConvert();
        system.debug('2');
        leadConvert.setLeadId(LeadIds[0]);

        system.debug('3');
        LeadStatus LeadStat= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];

        system.debug('4');
        leadConvert.setConvertedStatus(LeadStat.MasterLabel);
        //Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to   create an opportunity from Lead Conversion 

        system.debug('5');
        Database.LeadConvertResult lcr = Database.ConvertLead(leadConvert);
        system.debug('6');
        System.assert(lcr.isSuccess());
        system.debug('7');
    }
}

Test Class:
@isTest
private class AutoConvertLeadsTest {

    @isTest static void testLeadConversion() {
        Lead Ld = new Lead();
        Ld.FirstName = 'TestFirstName';
        Ld.LastName = 'TestLastName';
        Ld.Company = 'TestCompany';
        Ld.LeadSource = 'Web';
        Ld.Rating = 'Warm';
        Ld.Status = 'Open - Not Contacted';
        Ld.Email = 'test@testdwr.com.zz';
        system.debug('a');
        insert Ld;
        system.debug('b');
        Ld.Rating = 'Hot';
        update Ld;
        system.debug('c');

    }
}

When I edit the LeadSource = 'Web' and Rating = 'Hot' on the UI it kicks off the Process and then Apex code.
I get the following error:
Review the errors on this page.
We can't save this record because the “Auto Convert Lead” process failed. Give your Salesforce admin these details. An Apex error occurred: System.DmlException: ConvertLead failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?: [] Error ID: 839700365-14885 (-1370628323)


I am mystified what the source of the error is.
Hoping you can help me.
Created my first VF Page today.
How do I get rid of the white space that takes up half of the component in a Lightning page?

User-added image
I want to add a custom Highlights component to a Lightning Record Page. I have never created a Visualforce Page for adding to a Lightning canvas.
I may be way off the mark but gave it a go.
Any tips to get this working would be great!

<apex:page standardController="Opportunity">
    
    <apex:pageBlock title="Opportunity Summary">
        <apex:pageBlockTable value="{!Opportunity}" var="opp">
            <apex:column title="Customer(s)"/>
              <apex:column title="Guarantor(s)"/>
              <apex:column title="Lender"/>
              <apex:column title="Lender ID"/>
              <apex:column title="Broker"/>
              <apex:column title="Broker Code"/>
              <apex:column title="Loan Amount"/>
              <apex:column title="Close Date"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp1">
              <apex:column value="{!opp1.Applicant_1__c}"/>
              <apex:column title="Guarantor 1"/>
            <apex:column value="{!opp1.Lender__c}"/>
              <apex:column value="{!opp1.Account.Lender_ID__c}"/> <!-- Get customer field on Account object -->
              <apex:column value="{!opp1.User.FullName}"/> <!-- Get name of Opportunity Owner -->
              <apex:column value="{!opp1.User.AFG_Code__c}"/> <!-- Get custom field on User object -->
              <apex:column value="{!opp1.Amount}"/>
              <apex:column value="{!opp1.CloseDate}"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp2">
              <apex:column value="{!opp2.Applicant_2__c}"/>
              <apex:column title="Guarantor 2"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

Current Error Message: Invalid field USER for sObject Opportunity.
I am sure there are more errors.