• Avishek Nanda 14
  • NEWBIE
  • 322 Points
  • Member since 2017
  • Salesforce Developer / Consultant
  • Amazon.com , Inc

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 73
    Replies
Hi Friends,

I have created a custom controller and a vf page and when I run the vf page I am getting List has no Rows error.

Kindly needed your help to resolve this issue.

Below is my class and VF code.
 
Apex Class:

public class quoteController {

    private final SBQQ__Quote__c quotePDF;
    private final SBQQ__Quote__c quoteOpp;
    private final SBQQ__Quote__c quoteProd;

    public quoteController() {
        // Query for QuoteLineItem
        quotePDF = [SELECT Id, SBQQ__Account__r.Name, SBQQ__BillingCity__c, SBQQ__BillingName__c, SBQQ__ShippingCity__c, SBQQ__ShippingName__c, 
                           (Select Id, SBQQ__ProductName__c, SBQQ__Quantity__c, SBQQ__Description__c, SBQQ__ListPrice__c, SBQQ__NetTotal__c from SBQQ__LineItems__r) 
                      FROM SBQQ__Quote__c
                      WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    
        // Query for Quote Opportunity
        quoteOpp = [SELECT Id, SBQQ__Opportunity2__r.Vehicle_Make__c, SBQQ__Opportunity2__r.Rego_Fleet_Number__c, SBQQ__Opportunity2__r.Vin_Number__c, SBQQ__Opportunity2__r.Odometer__c, 
                           SBQQ__Opportunity2__r.Vehicle_Model__c
                      FROM SBQQ__Quote__c
                      WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
                      
        // Query for Quote Product
        quoteProd = [SELECT Id, (Select Id, SBQQ__Product__r.Refrigeration_Gas__c
                               from SBQQ__LineItems__r)
                       FROM SBQQ__Quote__c
                       WHERE Id = :ApexPages.currentPage().getParameters().get('id')];    

    }

    public SBQQ__Quote__c getquotePDF(){
        return quotePDF; 
    }
    
    public SBQQ__Quote__c getquoteOpp(){
        return quoteOpp;
    }
    
    public SBQQ__Quote__c getquoteProd(){
        return quoteProd;
    }
}
 
VF Page:

<apex:page controller="quoteController" tabStyle="SBQQ__Quote__c" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html>               
        <body> 
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quotePDF}" var="myOrder">                    
                <apex:column value="{!myOrder.SBQQ__Account__r.Name}" />        
                <apex:column value="{!myOrder.SBQQ__BillingCity__c}" />        
                <apex:column value="{!myOrder.SBQQ__BillingName__c}" />
                <apex:column headerValue="QTY">
                    <apex:outputText value=" " />
                </apex:column>
                <apex:column value="{!myOrder.SBQQ__ShippingCity__c}" />        
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quoteOpp}" var="quoteOpp">                    
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Make__c}" />        
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Rego_Fleet_Number__c }" />        
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vin_Number__c }" />
                <apex:column headerValue="QTY">
                    <apex:outputText value="{!quoteOpp.SBQQ__Opportunity2__r.Odometer__c}" />
                </apex:column>
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Model__c}" />
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quotePDF.SBQQ__LineItems__r}" var="OrderItems" >
                <apex:column headerValue="Product Name">
                    <apex:outputField value="{!OrderItems.SBQQ__ProductName__c}"/>
                </apex:column>
                <apex:column headerValue="PartNumber">
                    <apex:outputField value="{!OrderItems.SBQQ__Quantity__c}"/>
                </apex:column>
                <apex:column headerValue="Item Type">
                    <apex:outputField value="{!OrderItems.SBQQ__Description__c}"/>
                </apex:column>
                <apex:column headerValue="Option Type">
                    <apex:outputText value="{!OrderItems.SBQQ__ListPrice__c}"/>
                </apex:column>
                <apex:column headerValue="Value">
                    <apex:outputField value="{!OrderItems.SBQQ__NetTotal__c}"/>
                </apex:column>                                                                              
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quoteProd.SBQQ__LineItems__r}" var="prod" >
                <apex:column headerValue="Refrigeration Gas">
                    <apex:outputField value="{!prod.SBQQ__Product__r.Refrigeration_Gas__c}"/>
                </apex:column>
                                -->                                            
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
           
        </body>
    </html>    
</apex:page>

Thanks in Advance.
 hi All,
i Created a map in which i am taking two ids as key .i created the map as below:-
 Map<Id,FBG_Family__c> mapAlreadyexitFamily = new Map<Id,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company__c);
            mapAlreadyexitFamily.put(key,existFamily);
        }
but its giving me error:- Invalid id: nullnull.
how can i create a map having two ids as a key and get value related to that key which is  a record.
Any suggestions, how to do it?
Hi All,

I have designed a lightning component to insert products under one of custom object.

I can use same component in any custom objects without changing piece of code, i am storing the parent object fields api names in custom setting,

when inserting products i need to bind parent fields api names from custom settings.

I have searched a lot in google, still i am not able to find solution to achive this.

Thanks.
Hi,
I am new to Salesforce. I am working on 'Use Data Loader to Export Data' project. I downloaded Data Loader and clicked 'Export' and 'Password Authentication' as instructed. I put my developer edition user name and password, salesforce login URL default is 'https://login.salesforce.com. when I clicked 'login', I got error message 'check your username and password. If you still can't login, contact your administrator'.
Can anyone please help me? Thank you!
Hi all,
I have an uploaded an file in opportunity object  and i want to generate a public link automatically without clicking on public link button..............
can anyone help me
Thanks In advance.........
  • May 17, 2018
  • Like
  • 0
hi ,

i've written a code to show account details but its not working.kindly help as it is not throwing any error and there is also data in list<Account> in apex class.

Vf code :

<apex:page controller="accountInformation">
<apex:pageblock title="Accounts" >
<!--
<apex:repeat value="{!accs}" var="a">
<apex:pageblocksection >
<apex:outputlabel value="{!a.Name}"/>
<apex:outputfield value="{!a.Phone}"/>
<apex:outputfield value="{!a.Active__c}"/>
<apex:outputfield value="{!a.CleanStatus}"/>
</apex:pageblocksection>
</apex:repeat>
-->
<apex:pageblockTable value="{!accs}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Phone}"/>
<apex:column value="{!a.Active__c}"/>
<apex:column value="{!a.CleanStatus}"/>

</apex:pageblockTable>

</apex:pageblock>


</apex:page>

apex class:

public class accountInformation {


public list<Account> accs{ get; set;}

public list<Account> getAccounts(){

accs=[select Name,Phone,Active__c,CleanStatus from Account];
system.debug('Account info:'+accs);
return accs;
}

}
Is it possible to create a trigger that will allow no one, except system administrators, to create two opportunities of the same type on the Account object?  So, if someone has already created an equipment opportunity, another person could not create another equipment opportunity on the account.  I had originally thought this would be a validation rule and now I have no idea what to do.  Please advise.

The Apex Trigger: 

Trigger AutoConvert on Lead (after insert) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted && lead.Company == null) {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.Name;
               
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(true);
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}


The test class for the old trigger:

@IsTest
private class AutoConverter_Test {
    private static Integer LEAD_COUNT = 0;
    
    private static Lead createLead() {
        LEAD_COUNT += 1;
        return new Lead(
            FirstName = '_unittest_firstname_: ' + LEAD_COUNT,
            LastName = '_unittest_lastname_: ' + LEAD_COUNT,
            Company = '_unittest_company_: ' + LEAD_COUNT,
            Status = 'Inquiry'
        );
    }
    
    public static void makeFreeTrial(Lead lead) {
        lead.Company = null;
    }
    
    public static List<Lead> fetchLeads(Set<Id> ids) {
        return [
            select isConverted
            from Lead
            where Id in :ids
        ];
    }
    
    public static testMethod void trialConvert() {
        Lead testLead = createLead();
        makeFreeTrial(testLead);

        Test.startTest();
        
        insert testLead;
        
        Test.stopTest();
        
        List<Lead> results = fetchLeads(new Set<Id>{testLead.Id});
        
        System.assertEquals(1, results.size(), 'Did not get the right number of leads back');
        System.assert(results.get(0).isConverted, 'The lead should have been converted since it was a "Free Trail"');
    }

    public static testMethod void nonTrialNoConvert() {
        Lead testLead = createLead();
        
        Test.startTest();
        
        insert testLead;
        
        Test.stopTest();
        
        List<Lead> results = fetchLeads(new Set<Id>{testLead.Id});
        
        System.assertEquals(1, results.size(), 'Did not get the right number of leads back');
        System.assert(!results.get(0).isConverted, 'The lead should not have been converted since it was not a "Free Trail"');
    }
    
    public static testMethod void bulkTest() {
        List<Lead> shouldBeConverted = new List<Lead>();
        List<Lead> shouldNotBeConverted = new List<Lead>();
    
        for (Integer i = 0; i < 50; i++) {
            Lead testLeadNonConvert = createLead();
            Lead testLeadConvert = createLead();
            makeFreeTrial(testLeadConvert);
            
            shouldBeConverted.add(testLeadConvert);
            shouldNotBeConverted.add(testLeadNonConvert);
        }
        
        List<Lead> toInsert = new List<Lead>();
        toInsert.addAll(shouldBeConverted);
        toInsert.addAll(shouldNotBeConverted);
        
        Test.startTest();
        
        insert toInsert;
        
        Test.stopTest();
        
        Map<Id, Lead> expectedConversions = new Map<Id, Lead>(shouldBeConverted);
        Map<Id, Lead> expectedNonConversions = new Map<Id, Lead>(shouldNotBeConverted);
        
        Set<Id> leadIds = new Set<Id>();
        leadIds.addAll(expectedConversions.keySet());
        leadIds.addAll(expectedNonConversions.keySet());
        
        for (Lead result: fetchLeads(leadIds)) {
            if (expectedConversions.containsKey(result.Id)) {
                System.assert(result.isConverted, 'This lead should have been converted ' + result);
                expectedConversions.remove(result.Id);
            } else if (expectedNonConversions.containsKey(result.Id)) {
                System.assert(!result.isConverted, 'This lead should not have been converted ' + result);
                expectedNonConversions.remove(result.Id);
            } else {
                System.assert(false, 'We got a Lead we did not expect to get back ' + result);
            }
        }
        
        System.assert(expectedConversions.isEmpty(), 'We did not get back all the converted leads we expected');
        System.assert(expectedNonConversions.isEmpty(), 'We did not get back all the non converted leads we expected');
    }
}


Many Thanks!! :)

Natasha

Hello,

I have below use case to execute.

I have a standard button on opportunity, to clone with and without products.
I want to add an option to this clone button. like do XYZ, if user chooses this XYZ, it will execute few actions. if they choose the standard options, it remains the same.

Thank you for suggestions !
please help me...
i have an one profile xyz that have an multiple users.xyz profile has full access permission.
my question is to restrict only one user to delete permission on that profile.
can i use trigger?then reply me code pls....

thanks.
How do i set up a debug log in the developer console?
I need to know the step by step debugging of my code.
Hi all,
My trigger is being called twice, even I have used a static variable. Please find the class.
public void decommissioning(List<Incident>newlist,map<id,incident>oldmap) 
{
      if(checkrecursive.run==true)
 {
       serverdecomissioning(newlist,oldmap);
    checkrecursive.run=false;
}
}
public void serverdecomissioning(List<Incident>newlist1,map<id,incident>oldmap1)
{
//code
}

 
I have a map like this which cointain the all the value like id=userid and the values from account field (Account.abc__c
)and case field(Case.xyz__c).

map<Id,list<String>> UserwithCars = new map<Id,list<String>>();

Case.xyz__c (consider it as a brand)
Account.abc__c (consider it as sub-brand)


when user creates the case record  with the account 

I want to strore the userid of the user based on the Case.xyz__c value to the below 
ie is if the UserwithCars map cointains the value which is present in Case.xyz__c then it should add userid to the below list 

List<String> listUsersWithMatchingModel = new List<String>(); 
 
I am working on creating list view button which can pass selected id's to visualforce page but some how vf page is unable to catch those selected id's.
In classis I used javascript buttons but can anyone help me out how to do this in lightning. My code is below.

Apex Class:
public with sharing class PaymentSummaryController {
    
   
    public boolean InError {get;set;}
    
    public decimal TotalAmount {get;set;}
    public decimal TotalAppliedAmount {get;set;}
    public integer TotalItems {get;set;}
    
    public List<String> selectedIds {get;set;}
   
    public PaymentSummaryController(ApexPages.StandardSetController controller) {
       
        InError=false;
        controller.setPageSize(1000); 
        
        String str = ApexPages.currentPage().getParameters().get('selectedIds');
        if(str !=null)
            selectedIds = String.escapeSingleQuotes(str).split(',');
        
        
        if (selectedIds==null || selectedIds.size()==0) {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please select at least one record.');
            ApexPages.addMessage(myMsg);
            InError=true;
        } 
        else {
            TotalAmount=0;
            TotalAppliedAmount=0;
            TotalItems=0;
            for (EXECED_Payment__c p : [select id,Amount__c,Total_Applied_Amount__c from EXECED_Payment__c where id in: selectedIds]){
                if (p.Amount__c!=null)
                    TotalAmount+=p.Amount__c;
                if (p.Total_Applied_Amount__c!=null)
                    TotalAppliedAmount+=p.Total_Applied_Amount__c;
                TotalItems++;
            }
        }
     } 
    
   
   
}
Visualforce page:
<apex:page standardController="EXECED_Payment__c" sidebar="false" showHeader="false" extensions="PaymentSummaryController" recordSetVar="payments" lightningStylesheets="true">
    
    <apex:form > 
        <apex:pagemessages />
        <apex:outputPanel rendered="{!inError}">
            <apex:commandButton action="{!Cancel}" value="Cancel"/>    
        </apex:outputPanel>
        
       
        <apex:outputpanel rendered="{!not(InError)}">
            <br/>
            <table>
                <tr>
                    <td><apex:outputtext value="Number of payments selected:"/></td>
                    <td><apex:outputtext style="font-weight:bold;" value="{!TotalItems}"/></td>
                </tr>
                <tr>
                    <td><apex:outputtext value="Total Amount:"/></td>
                    <td><apex:outputtext style="font-weight:bold;" value="{!TotalAmount}"/></td>
                </tr>
                 <tr>
                    <td><apex:outputtext value="Total Applied Amount:"/></td>
                    <td><apex:outputtext style="font-weight:bold;" value="{!TotalAppliedAmount}"/></td>
                </tr>
            </table>
            
           
          <!--  <br/><br/>
            <apex:commandButton action="{!Cancel}" value="Return"/>      -->
        </apex:outputpanel>
       
    </apex:form>
</apex:page>


 
Hi Friends,

I have created a custom controller and a vf page and when I run the vf page I am getting List has no Rows error.

Kindly needed your help to resolve this issue.

Below is my class and VF code.
 
Apex Class:

public class quoteController {

    private final SBQQ__Quote__c quotePDF;
    private final SBQQ__Quote__c quoteOpp;
    private final SBQQ__Quote__c quoteProd;

    public quoteController() {
        // Query for QuoteLineItem
        quotePDF = [SELECT Id, SBQQ__Account__r.Name, SBQQ__BillingCity__c, SBQQ__BillingName__c, SBQQ__ShippingCity__c, SBQQ__ShippingName__c, 
                           (Select Id, SBQQ__ProductName__c, SBQQ__Quantity__c, SBQQ__Description__c, SBQQ__ListPrice__c, SBQQ__NetTotal__c from SBQQ__LineItems__r) 
                      FROM SBQQ__Quote__c
                      WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    
        // Query for Quote Opportunity
        quoteOpp = [SELECT Id, SBQQ__Opportunity2__r.Vehicle_Make__c, SBQQ__Opportunity2__r.Rego_Fleet_Number__c, SBQQ__Opportunity2__r.Vin_Number__c, SBQQ__Opportunity2__r.Odometer__c, 
                           SBQQ__Opportunity2__r.Vehicle_Model__c
                      FROM SBQQ__Quote__c
                      WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
                      
        // Query for Quote Product
        quoteProd = [SELECT Id, (Select Id, SBQQ__Product__r.Refrigeration_Gas__c
                               from SBQQ__LineItems__r)
                       FROM SBQQ__Quote__c
                       WHERE Id = :ApexPages.currentPage().getParameters().get('id')];    

    }

    public SBQQ__Quote__c getquotePDF(){
        return quotePDF; 
    }
    
    public SBQQ__Quote__c getquoteOpp(){
        return quoteOpp;
    }
    
    public SBQQ__Quote__c getquoteProd(){
        return quoteProd;
    }
}
 
VF Page:

<apex:page controller="quoteController" tabStyle="SBQQ__Quote__c" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html>               
        <body> 
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quotePDF}" var="myOrder">                    
                <apex:column value="{!myOrder.SBQQ__Account__r.Name}" />        
                <apex:column value="{!myOrder.SBQQ__BillingCity__c}" />        
                <apex:column value="{!myOrder.SBQQ__BillingName__c}" />
                <apex:column headerValue="QTY">
                    <apex:outputText value=" " />
                </apex:column>
                <apex:column value="{!myOrder.SBQQ__ShippingCity__c}" />        
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="95%" value="{!quoteOpp}" var="quoteOpp">                    
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Make__c}" />        
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Rego_Fleet_Number__c }" />        
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vin_Number__c }" />
                <apex:column headerValue="QTY">
                    <apex:outputText value="{!quoteOpp.SBQQ__Opportunity2__r.Odometer__c}" />
                </apex:column>
                <apex:column value="{!quoteOpp.SBQQ__Opportunity2__r.Vehicle_Model__c}" />
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quotePDF.SBQQ__LineItems__r}" var="OrderItems" >
                <apex:column headerValue="Product Name">
                    <apex:outputField value="{!OrderItems.SBQQ__ProductName__c}"/>
                </apex:column>
                <apex:column headerValue="PartNumber">
                    <apex:outputField value="{!OrderItems.SBQQ__Quantity__c}"/>
                </apex:column>
                <apex:column headerValue="Item Type">
                    <apex:outputField value="{!OrderItems.SBQQ__Description__c}"/>
                </apex:column>
                <apex:column headerValue="Option Type">
                    <apex:outputText value="{!OrderItems.SBQQ__ListPrice__c}"/>
                </apex:column>
                <apex:column headerValue="Value">
                    <apex:outputField value="{!OrderItems.SBQQ__NetTotal__c}"/>
                </apex:column>                                                                              
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
        
        <apex:pageBlock >
            <apex:pageBlockTable columns="5" border="1" cellspacing="0" cellPadding="5" width="100%" value="{!quoteProd.SBQQ__LineItems__r}" var="prod" >
                <apex:column headerValue="Refrigeration Gas">
                    <apex:outputField value="{!prod.SBQQ__Product__r.Refrigeration_Gas__c}"/>
                </apex:column>
                                -->                                            
            </apex:pageBlockTable>
        </apex:pageBlock> <p class="onepointfive"/>
           
        </body>
    </html>    
</apex:page>

Thanks in Advance.
Hi All,
        i have created the batch in which i am creating  Custom object records for duplicate accounts.
        when i run  the batch i have null pointer exeption at bold lines.
        my batch is given below:-
        
        //Batch to create FBGFamily junction records for Account having same name
public class BatchFBGFamilies implements Database.Batchable<sObject> {
    //run method to execute batch on one record
    public static void run( Set<Id> AccIds ) {
        List<Account> accountRecords =  [Select id, Name  
                                         From Account
                                         Where Id IN:  AccIds ];
        executeHelper( accountRecords );                  
    }
    //Start method to get All Account which is exetuing batch
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'Select Id, Name ' +
            'FROM Account';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Account> accounts){
        executeHelper( accounts );
    }
    
    public void finish(Database.BatchableContext BC){
    }
    
    //method to perform record creation of junction object for Account having same name
    public static void executeHelper( List<Account> accounts ) {
        //set to get Account having duplicate name
        Set<String> duplicateNames = new Set<String>();
        for (Account account : accounts)
        {
            duplicateNames.add(account.Name);
        }
        
        //map to get Account name and list of AccountIds having same name
        Map<String, List<Account>> mapDuplicateAccNameToIds = new Map<String, List<Account>>();
        for(Account acc : [SELECT id,name FROM Account  where Name IN: duplicateNames AND Id NOT IN : accounts]) {
            if(mapDuplicateAccNameToIds.containsKey(acc.Name)) {
                List<Account> ListDuplicates = mapDuplicateAccNameToIds.get(acc.Name);
                ListDuplicates.add(acc);
                mapDuplicateAccNameToIds.put(acc.Name, ListDuplicates);
            } else {
                mapDuplicateAccNameToIds.put(acc.Name, new List<Account> { acc });
            }
        }
        Map<String,FBG_Family__c> mapAlreadyexistFamily = new Map<String,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company2__c);
            mapAlreadyexistFamily.put(key,existFamily);
        }
        //System.debug('Already exit'+mapAlreadyexistFamily);
        
        //creating junction object records
        List<FBG_Family__c> ListFBGFamily = new List<FBG_Family__c>();
        for (Account acc : accounts)
        {
            List<Account> DuplicateAccount = mapDuplicateAccNameToIds.get(acc.Name);
            System.debug('DuplicateAccount'+DuplicateAccount);
            for(Account Acc1 : DuplicateAccount ){    //here its giving null pointer exeption
                FBG_Family__c Family =  new FBG_Family__c();
                Family.Sister_Company__c =  acc.id;
                if( acc.Id != Acc1.Id){
                    Family.Sister_Company2__c = Acc1.id;
                    String key = String.valueOf(Family.Sister_Company__c) + String.valueOf(Family.Sister_Company2__c);
                    if(!mapAlreadyexistFamily.containsKey(key)){
                        ListFBGFamily.add(Family); 
                    }
                    
                } 
            }
        }
        if( ListFBGFamily.Size() > 0 ){
            FBGFamilyTriggerHelper.runTrigger = FALSE;
            Insert ListFBGFamily;
        }
    }
}
        how to solve this any suggestions?
 hi All,
i Created a map in which i am taking two ids as key .i created the map as below:-
 Map<Id,FBG_Family__c> mapAlreadyexitFamily = new Map<Id,FBG_Family__c>();
        for(FBG_Family__c existFamily : [select id, Name, Sister_Company__c, Sister_Company2__c FROM FBG_Family__c ]){
            String key = String.valueOf(existFamily.Sister_Company__c) + String.valueOf(existFamily.Sister_Company__c);
            mapAlreadyexitFamily.put(key,existFamily);
        }
but its giving me error:- Invalid id: nullnull.
how can i create a map having two ids as a key and get value related to that key which is  a record.
Any suggestions, how to do it?
Hi,

I need some help to adjust this trigger so that it only fires off when the record count is > 14 and <  16. The user group only wants to be notified the first time the queue hits 15 cases so this will limit the notifications. I'm not sure how to add the range logic to the code.

This is the code we have but the trigger is firing each time new case hits the queue and is not respecting the limits we tried.

Any ideas or help on why this happens and how to resolve it would be appreciated.

trigger Notificationexceedingqueuelimit on Case (after insert,after update) {
    list<group> queuelist= [SELECT id  FROM Group where DeveloperName = 'CPS_Default_Queue'and Type = 'Queue' limit 1]; 
    
    
    
    if(queuelist.size()>0){
        boolean isqueuecase = false;
        for(case cs : trigger.new){
            if(cs.ownerid == queuelist[0].id){
                isqueuecase = true;
            }
        }
        if(isqueuecase = true){
            list<case> caselist = [select id from case where ownerid =:queuelist[0].id limit 16];
            if(caselist.size()>14 && caselist.size()<16 ){
                  List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                  List<String> sendTo = new List<String>();
                  sendTo.add('Mymail.com' );
                  mail.setHtmlBody('Hi, <br/> Default Queue Limit Exceeded. The count has exceeded 15 cases. <br/><br/> Thanks, <br/>Salesforce Admin');
                  mail.setSubject('Case Limit Exceeded');
                  mail.setToAddresses(sendTo);
                  mails.add(mail);   
                  Messaging.sendEmail(mails);   
            }
        
        }
    }
public class EmailInvoiceA {
    
    @auraEnabled
    public static void sendMailWithPDF(String recordId){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           sendTo.add(cc.Distributor__r.E_mail__c);
            
            List<String> send = new List<String>();
            if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
            {  
                send.add(cc.Distributor__r.CC_to_if_any__c);
               semail.setToAddresses(send);
            }
            else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
            {
                sendTo.add(cc.Distributor__r.E_mail__c);
                send.add(cc.Distributor__r.CC_to_if_any__c);
              semail.setccAddresses(send);
              semail.setToAddresses(sendTo);
                
           }
           else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
            {  
              sendTo.add(cc.Distributor__r.E_mail__c);
                   semail.setToAddresses(sendTo);
         }
                mails.add(semail);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }      
    @auraEnabled
     public static void sendMailWith(String recordId,String mMail){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            sendTo.add(mMail);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
           
              List<String> send = new List<String>();
            if(cc.Distributor__r.CC_to_if_any__c != null)
            {
                 send.add(cc.Distributor__r.CC_to_if_any__c);
                 
            }
            mails.add(semail);
			semail.setCcAddresses(send);
            semail.setToAddresses(sendTo);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }    
     @auraEnabled
   public static void Mail(String recordId,String mMail,boolean checkCmp){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
  
           if(checkCmp==true)
               {
                  sendTo.add(mMail);
                   semail.setToAddresses(sendTo);
               }
           else  if(checkCmp==false)
            {
              if(mMail != null)
            {
                sendTo.add(mMail);
            	semail.setToAddresses(sendTo);
            }   
             if(cc.Distributor__r.E_mail__c != null)
            {
               sendTo.add(cc.Distributor__r.E_mail__c);  
                semail.setToAddresses(sendTo);
            } 
                
             if(cc.Distributor__r.CC_to_if_any__c != null)
            { 
                List<String> send = new List<String>();//cc string
				send.add(cc.Distributor__r.CC_to_if_any__c);  
               semail.setCcAddresses(send);
           }   
            }
            mails.add(semail);

            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }       
}

 
Hi Everyone,
Plz tell me how to add child records in sequence.Here is the code.Suppose in 3 contact associated with account (Ex Contact name Contact0,Contact1,Contact2).On Account field Number of Location field value is 3.if i change to 6 then (Contact0, Contact1,Contact3 ) inserting again.I need to add Contact4,Contact5,Contact 6 while Updating.

Here is the code:-

trigger ContactCreation on Account (after insert,after update) {
    List<Contact> conList = new List<Contact>();
    Map<Id,decimal> mapAcc = new Map<Id,decimal>();
    
    for(Account a : trigger.new){
        mapAcc.Put(a.Id,a.NumberofLocations__c);
    }
    if(mapAcc.size() > 0 && mapAcc != null){
        for(Account acc : trigger.new){
            
            for(Integer i=0;i<mapAcc.get(acc.id);i++){
                Contact con = new Contact();
                con.AccountId = acc.Id;
                con.LastName = 'Contact'+i;
                conList.add(con);
            }   
        }
    }
    
    if(conList.size() > 0 && conList != null){
        insert conList;
    }   
    List<Contact> listcon = new List<Contact>([Select Id,Name From Contact]);
    for(Contact c : listCon){
        
    }
}

Thanks in Advance !!


 
Hi All,

I have designed a lightning component to insert products under one of custom object.

I can use same component in any custom objects without changing piece of code, i am storing the parent object fields api names in custom setting,

when inserting products i need to bind parent fields api names from custom settings.

I have searched a lot in google, still i am not able to find solution to achive this.

Thanks.
Hi All,
i want to creat a NEW button on lead which is related to Account.
How to do it?
Any suggestion?
Email to case and Web to case and Web to lead functionalities how to migrate from Sandbox to production and how it will work like ex: for email to case Salesforce will give one big routing address so how we will manage this, also web to case/lead functionalities it will give us HTML code, how we can manage these all
hello I am tryogn to mkae the record# as the link to the record detail page from VF.Please help:
Below is the part of VF page for that section:
i am tryign to make putReservation as a link:

<apex:pageBlockSection title="Conference Room Reservation" columns="1">
         <table>
             <tr><td id='firsrTD'> <span class='firstSpan'>Reservation #: </span></td><td><span id='putReservation'></span></td></tr>
             <tr><td>  <span class='firstSpan'>Meeting Title: </span></td><td><span id='putTitle'></span></td></tr>
             <tr><td>  <span class='firstSpan'>Reservation status: </span> </td><td> <span id='putStatus'> </span></td></tr>
Extreme newbie here.  I need to be able to send an email to person from an opportunity and then when the user responds download the attachment Is there any code out there for this?  Any help would be greatly appreciated
I have a before delete trigger on Topic Assignment that I'm using to block a User from deleting a Topic from a Question in a lightning community. The trigger works fine and blocks the DML, however the error message is not User friendly and I cannot figure out how to get it to display ONLY my error message.
What's odd is that it seems to work for Trigger.new. Help is appreciated.

trigger TopicAssignmentTrigger on TopicAssignment (before delete) {
for(TopicAssignment ta : Trigger.old){
//Conditional logic will go here
ta.addError('CANNOT DELETE THIS TOPIC'); }
}

User-added image