• ravikanth321
  • NEWBIE
  • 25 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 20
    Replies

In below report for account my total quote count should be 5(unique quote dates in a opportunity ) not 6 ,1,2,3 are from same opp with diff quote date,4 and 5 are with same quote date on single opportunity,6th is for single opp -single quote so my total quote count should be 5 .How to make this unique calculation based on quote date grouped by account.

User-added image
Hi Could someone help me in creating a batch apex to count(total 6 stages ,i want to count only 2 and above) the number of opportunities owned by a user and populate that value on to user record.
ApexClass::::
public class ActiveContactEditController{

    public Id recordTypeId{get;set;}
    public Id contactId{get;set;}
    public Contact con;
    public String profileName{get;set;}
    public Contact con1{get;set;}
    private ApexPages.StandardController sc;
    public Boolean editFlag{get; set;}
    public set<String> setOfUserPermissionSets{get;set;}
    public string mulId;
    public string mulId2;
    private List<sObject> duplicateRecords;
    private final Contact contact;
    public boolean hasDuplicateResult{get;set;}
    
    public boolean save_dup {get;set;}
    public boolean save_dup_ignore {get;set;}
    public boolean save_dup_ignorenew {get;set;}
    public boolean Test {get;set;}
        
    public ActiveContactEditController(ApexPages.StandardController controller){
    
    save_dup = false;
    save_dup_ignore = false;
    save_dup_ignorenew = false;
    Test = true;
    
     // Define the values for the contact you’re processing based on its ID
        Id id = ApexPages.currentPage().getParameters().get('id');
        this.contact = (id == null) ? new Contact() :
            [SELECT Id, FirstName, LastName
             FROM Contact WHERE Id = :id];
       
        // Initialize empty list of potential duplicate records
        this.duplicateRecords = new List<sObject>();
        this.hasDuplicateResult = false;
    
    
        this.sc = controller;
        con1 = new Contact();
       
         
        List<Schema.RecordTypeInfo> infos = Schema.SObjectType.Contact.RecordTypeInfos;
        Id defaultRecordTypeId;
        editFlag = false;
        //check each one
        for (Schema.RecordTypeInfo info : infos) {
          
          if (info.DefaultRecordTypeMapping) {
            
            defaultRecordTypeId = info.RecordTypeId;
            
            mulId = defaultRecordTypeId;
            mulId2 = mulId.substring(0,mulId.length()-3);
            
            system.debug('defaultRecordTypeId ' + mulId2);
          }
        }

        if(Apexpages.currentpage().getparameters().get('RecordType') != NULL){
        
            recordTypeId = Apexpages.currentpage().getparameters().get('RecordType');
            system.debug('******* recordTypeId ******  ' + recordTypeId );
           
            if(String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID))
            con1.Active__c = true;
            
            if(String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID))
            con1.Small_Market__c = true;
         
            
        }
        if(Apexpages.currentpage().getparameters().get('Id') != NULL){
        
            contactId = Apexpages.currentpage().getparameters().get('Id');
            system.debug('contactId ' + contactId );
            con = [SELECT RecordtypeId from contact where id =: contactId];
            recordTypeId = con.RecordtypeId;
            
           
            
            if(contactId != null)
            editFlag = true;
        }
        if(recordTypeId == NULL){
        
            //recordTypeId = defaultRecordTypeId;
            recordTypeId  = String.valueOf(mulId2) ;
            system.debug('testing mulid '+recordTypeId  );
            system.debug('testing mulid '+mulId2);
            con1.Active__c = true;
            con1.Customer_Type__c = 'Active-Primary';
            con1.Input_Type__c = 'Manual';
            system.debug('con1.Customer_Type__c'+con1.Customer_Type__c);
            system.debug('con1.Input_Type__c'+con1.Input_Type__c);
        }
        
    }
    
    
    public List<sObject> getDuplicateRecords() {
        return this.duplicateRecords;
    }
 
    public boolean getRedirect(){
 
        if((recordTypeId != Label.Active_RecordTypeID || recordTypeId != Label.SM_Customer_RecordTypeID) && contactId == NULL){
        
            return true;
        }
        else{
        
            return false;
        }
    }
    
    public PageReference nextPage(){
    
        String ContactName;
        String relatedToFieldId = 'CF'+Label.Related_to_field_id+'_lkid';
        Id parentId = Apexpages.currentpage().getparameters().get(relatedToFieldId);
        if(parentId!= NULL){
        Contact conObj = [SELECT Salutation,FirstName,MiddleName, LastName from Contact where id =: parentId];
         /*** Forming Contact fullname  to use in URL ***/                  
         String Salutation = '';
         String FirstName = '';
         String MiddleName = '';
         String LastName = '';
         
         if(conObj.Salutation != NULL )
          Salutation = conObj.Salutation + '+';
         
         if(conObj.FirstName != NULL )
          FirstName = conObj.FirstName + '+';
        
         if(conObj.MiddleName != NULL )
          MiddleName = conObj.MiddleName + '+';
          
          LastName = conobj.LastName;
          
          ContactName = Salutation + FirstName + MiddleName + LastName;
         }
        system.debug('recordTypeId '+ recordTypeId );
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        if(recordTypeId != NULL && parentId != NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID) ) && !String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId) && contactId == NULL){
        
            system.debug('Error1');
            PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&CF'+Label.Related_to_field_id+'='
              +ContactName+'&'+relatedToFieldId+'='+parentId + '&nooverride=1');

            return pRef;
        }
        
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        else if(recordTypeId!= NULL && parentId == NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)) && !String.valueOf(mulId2).contains(Label.Active_Retiree_RecordTypeId) && contactId == NULL){
          system.debug('Error2 ' + recordTypeId);
         
          PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&nooverride=1');
          
          return pRef;
        }
        
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        if(contactId != NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)) && !String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId)){
         system.debug('Error3');
            PageReference pRef = new PageReference('/'+contactId+'/e?&nooverride=1'+'%2F'+contactId+'&retURL='+contactId);
            return pRef;
        }
        else if(contactId != NULL && String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId) && (setOfUserPermissionSets.contains('MM_Read_Only') || setOfUserPermissionSets.contains('MM_RET_Account_Manager') || setOfUserPermissionSets.contains('MM_RET_BC') || setOfUserPermissionSets.contains('MM_RET_Claims_Analyst') || setOfUserPermissionSets.contains('MM_RET_Claims_Manager') || setOfUserPermissionSets.contains('MM_RET_Manager') || setOfUserPermissionSets.contains('MM_RET_Quality_Assurance') || setOfUserPermissionSets.contains('MM_RET_Team_Lead') || setOfUserPermissionSets.contains('MM_SM_OSD'))){
         system.debug('Error4');
            PageReference pRef = new PageReference('/'+contactId+'/e?&nooverride=1&retURL=/'+contactId);
            return pRef;
        }
        else if(contactId == NULL && String.valueOf(mulId).contains(Label.Active_Retiree_RecordTypeId) && (setOfUserPermissionSets.contains('MM_Read_Only') || setOfUserPermissionSets.contains('MM_RET_Account_Manager') || setOfUserPermissionSets.contains('MM_RET_BC') || setOfUserPermissionSets.contains('MM_RET_Claims_Analyst') || setOfUserPermissionSets.contains('MM_RET_Claims_Manager') || setOfUserPermissionSets.contains('MM_RET_Manager') || setOfUserPermissionSets.contains('MM_RET_Quality_Assurance') || setOfUserPermissionSets.contains('MM_RET_Team_Lead') || setOfUserPermissionSets.contains('MM_SM_OSD'))){
         system.debug('Error5');
            PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&nooverride=1&retURL=/003/o');
            return pRef;
        }
        else{
         system.debug('Error6');
            return NULL;
        }
    }

    public boolean validateDobandsocial(Contact conObj){
        Id acctId =conObj.AccountId;
        Date birthDt= conObj.DOB__c;
        String ssn = conObj.Social_Security_Number__c;
        Account accObj = [SELECT Id,Small_Market__c,Active__c,Client_Type__c from Account where id =: acctId];
        If (accObj.Active__c && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))){
            return false;
        }else if (accObj.Small_Market__c && accObj.Client_Type__c != 'Brokerage' && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))) {
            return false;
        }else if (accObj.Small_Market__c && accObj.Client_Type__c == 'Brokerage' && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))) {
            return true;
        }else {
            return true;
        }

     }

    public pageReference Test(){
      hasDuplicateResult = false ;  
    Boolean stayOnpage = false;
    Contact conObj =(Contact) sc.getRecord();    
    boolean validateResult =  validateDobandsocial(conObj);
     try{
        if(validateResult){
            if(contactId == NULL){
                stayOnpage = Test2(conObj);
               // insert conObj;
                }
            else{
               // stayOnpage = Test2(conObj);          
                update conObj;
               }
      
       if(stayOnPage == true)
       {
        save_dup_ignore = true;
        save_dup = true;
        save_dup_ignorenew = true;

        Test = false;
        return null;
       }
       else{
              
        PageReference saveAndRedirectPage = new PageReference('/apex/ActiveContactEditRedirectPage');
        saveAndRedirectPage.setRedirect(true);
        saveAndRedirectPage.getParameters().put('id', conObj.id);
        saveAndRedirectPage.getParameters().put('name', conObj.name);
        return saveAndRedirectPage;}
       }else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'BirthDate and/or SSN can not be blank'));
            return null;
        }
    }catch(Exception ex){
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'testvali1'+ex.getdmlMessage(0)));
    return null;
    }
 
    }
    
    public Boolean Test2(Contact conObj){

    hasDuplicateResult = true ;
 
        Database.DMLOptions dml = new Database.DMLOptions();
        dml.DuplicateRuleHeader.allowSave = true;
        dml.DuplicateRuleHeader.runAsCurrentUser = true;
         //Contact conObj =(Contact) sc.getRecord();
         
        Database.SaveResult saveResult = Database.insert(conObj, false);
      
        system.debug('The Test Debug after contact save on  savedupe');
        
       
         if (!saveResult.isSuccess()) {
         system.debug('The Test Inside after success savedupe');
            for (Database.Error error : saveResult.getErrors()) {
                // If there are duplicates, an error occurs
                // Process only duplicates and not other errors
                //   (e.g., validation errors)
                if (error instanceof Database.DuplicateError) {
                    // Handle the duplicate error by first casting it as a
                    //   DuplicateError class
                    // This lets you use methods of that class
                    //  (e.g., getDuplicateResult())
                    Database.DuplicateError duplicateError =
                            (Database.DuplicateError)error;
                    Datacloud.DuplicateResult duplicateResult =
                            duplicateError.getDuplicateResult();
                    
                    // Display duplicate error message as defined in the duplicate rule
                    ApexPages.Message errorMessage = new ApexPages.Message(
                            ApexPages.Severity.ERROR, 'Duplicate Error: ' +
                            duplicateResult.getErrorMessage());
                    ApexPages.addMessage(errorMessage);
                    
                    // Get duplicate records
                    this.duplicateRecords = new List<sObject>();

                    // Return only match results of matching rules that
                    //  find duplicate records
                    Datacloud.MatchResult[] matchResults =
                            duplicateResult.getMatchResults();

                    // Just grab first match result (which contains the
                    //   duplicate record found and other match info)
                    Datacloud.MatchResult matchResult = matchResults[0];

                    Datacloud.MatchRecord[] matchRecords = matchResult.getMatchRecords();

                    // Add matched record to the duplicate records variable
                    for (Datacloud.MatchRecord matchRecord : matchRecords) {
                        System.debug('MatchRecord: ' + matchRecord.getRecord());
                        this.duplicateRecords.add(matchRecord.getRecord());
                    }
                    this.hasDuplicateResult = !this.duplicateRecords.isEmpty();
                }
            }
            
            //If there’s a duplicate record, stay on the page
            //return null;
            return (true);
        }
        
        /******* END *******/  
        else
        return (false);

    }

}


 
Hii In this line of code ....              if(mapOfUserAssigns.containsKey(userinfo.getUserId()) && !mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r.isEmpty() && mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r[0].Authorized_States__c != null && mapOfUserAssigns.get(cntObj.OwnerId).Authorized_States__r[0].Authorized_States__c.contains(cntObj.MailingStateCode)){
I am getting Null Pointer exception ,On one existing contact owner is inactive ,I am  just editing state field on contact and saving after saving i am getting nullpointer exception..!
 
Hi i have two objects Account and Offer .On offer object i have two picklist fields using this two picklists i am showing/rendering  a table (vf component ) ,But now along with two picklist fields i have to render like this: Check the logged in user and under user there is a field called "See Headline as Partner" now i have to map this field value with account name in my org and under that  account i have a new text field called "product hierarchy " now i have to render the table based on already existed two picklists and this product hierarchy text field value.





 
Check Parent(Account) checkbox(Active__c ) when any one of child(Child__c) records checkbox(Primary__c)    is checked(We also have a validation where only one chilld record can have that checkbox checked) ....Uncheck Checkbox Active__c if checkbox primary__c is unchecked.



01trigger Primarycheck on Child__c(after insert, after update) {
02    list<Account > listofParentObjToUpdate;
03    set<Id> setOfids = new set<Id>();
04    Map<Id,Child__c> mapIdVschild = new  Map<Id,Child__c>();
05     
06    for(Integer i=0;i<Trigger.new.size();i++){
07        if(Trigger.new[i].Primary__c==true || Trigger.new[i].Primary__c==false){
08            mapIdVschild.put(Trigger.new[i].Child__c,Trigger.new[i]);
09        }
10    }
11    
12    if(!mapIdVschild.isEmpty()){
13        list<Account> listOfParentObj = [select id,Active__c from Account where Id IN: mapIdVschild.keySet()];
14         
15        listofParentObjToUpdate = new list<Account>();
16        for(Account parent : listOfParentObj) {
17            parent.Active__c=mapIdVschild.get(parent.id).Active__c;
18                listofParentObjToUpdate.add(parent);
19        }
20        Update listofParentObjToUpdate;
21    }          
22}
Please any help is welcome,Hi I would like to create a Record with the values captured/selected from radio button  once apex:Selectcheckbox is checked in Visualforce.Thank in Advance.


User-added image
Please help me with the below code,I want to show the belowpageblocksection only when "continue" button is clicked .
  <apex:pageBlock id="show">
            
             <apex:pageBlocksection title="Select Card Type :">
             <apex:pagemessages />
                <apex:selectRadio value="{!cardType}" layout="pageDirection" >
                    <apex:selectOptions value="{!cardOption}" >
                    </apex:selectOptions>
                    
                </apex:selectRadio><br />
                <apex:commandButton value="Continue" action="{!renderPage}" status="status" rerender="show"/>
                </apex:pageBlocksection>
                
                
                
                 <apex:pageBlocksection title="Select Offer :"  rendered="{!Continue}" >
                 <apex:selectRadio value="{!offerType}" layout="pageDirection" >
                    <apex:selectOptions value="{!offerOption}" >
                    </apex:selectOptions>
                    
                </apex:selectRadio><br />
                <apex:commandButton value="Select" action="{!renderOfferPage}" status="status"/>
            
                </apex:pageBlocksection>
            
            </apex:pageBlock>
Hii I have written a Code For Onclick Button Which has to disable after first click and has to call a method which converts lead in to Opportunity,Accounts and Contact..
Code:
{!REQUIRESCRIPT("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js")}
  var $ = jQuery.noConflict();
$(document).off('click', '.btn').on('click', '.btn',function(e) {
    $('input[name*=custom_convert]').attr('class', 'btnDisabled');
      $('input[name*=custom_convert]').attr('value','Converting...');
      
      console.log('*****clicked*********');
window.location='/apex/LeadConvertOverride?id={!Lead.Id}';
    });User-added image
 
Once you click on Convert button on lead page ,Its gets converted in to Oppurtinity,Account,Contact In Upfront or Redirects to Custom Lead conversion page Based on some fields missing.
Hii I had a Requirement where I have too avoid Creation of Multiple Accounts,Oppurtunities and Contact On Click Of Convert Button On  Stamdard Lead Page.
How To Disable the Standard Lead "Convert" Button On Click.

Hi Anything Wrong In My Trigger ,When I am Trying To Deploy a Test Class(In Test Class Ii am Just Inserting  Account,Oppurtunity,Cardapplication objcet) I am Getting This Below Error:
System.LimitException: Too many SOQL queries: 101 
Stack Trace: Trigger.UpdateEngagement: line 13, column 1
trigger UpdateEngagement on Opportunity (after insert, after update, before update) 
{
    if(Trigger.isInsert || (Trigger.isUpdate && Trigger.isAfter))
    {
        map<Id, string> mpOpp = new map<Id, string>();
        for(Opportunity o: Trigger.New)
        {
            mpOpp.put(o.AccountId, o.StageName);
        }
        
        If(mpOpp != null && mpOpp.size()>0)
        {
            List<Account> lstAcc = [select  EngagementCode__c, id from Account where id in :mpOpp.KeySet()];
            for(Account a: lstAcc)
            {
                a.EngagementCode__c = mpOpp.get(a.id);
            }
            update lstAcc;
        }
    }

    // New code added to Update the Incentive Options dependent field on stage change - by Vivek
 /*   if(Trigger.isUpdate && Trigger.isBefore)
    {
    
system.debug('@@1Before Incentive offer + Incentive'+Trigger.Old[0].Incentive__c);
        for(Opportunity OppNew : Trigger.New)
        {
            for(Opportunity OppOld : Trigger.Old)
            {
                if(OppNew.StageName != 'Product Recommendation' && OppOld.Incentive__c!='')
                {
                
system.debug('@@2Copying Incentive offer'+OppOld.Incentive__c);
                    OppNew.Incentive__c = OppOld.Incentive__c;
                }
            }
        }     
    } */
}
Hi I am Using Page Block Buttons Instead Of CommandButtons To Dispaly Buttons On Both Top and Bottom,I Have a Requirement where I have to Disable Button OnClick ,So We Can avoid Multiple Submissions.I Tried With PageBlock Buttons Disabling Is Working Fine But Onclick If any Button Either Top or Buttom i have to Disable Booth Buttoms...Any Ideas Plz...??? TIA.


<apex:pageBlock title="Test" id="pgblk">

<apex:pageMessages />

<apex:pageBlockButtons >
<apex:commandButton action="{!cancel}" value="Cancel"/>
<!--<apex:commandButton value="Convert" id="Convert"  action="{!convertLeadFunction}" />-->
<apex:commandButton value="Convert" action="{!convertLeadFunction}" onclick="disable" reRender="pgblk"/>


<!--<apex:commandButton value="Convert" action="{!convertLeadFunction}" onclick="alert('Please Wait Until Lead Gets Converted');"  /> -->

<!--<apex:actionStatus id="saveStatus">
    <apex:facet name="stop">
        <apex:commandButton value="Convert" action="{!convertLeadFunction}" status="saveStatus" rerender="saveParentBlock" />
    </apex:facet>
    <apex:facet name="start">
        <apex:commandButton value="Please Wait While Converting" disabled="true" status="saveStatus" rerender="saveParentBlock" />
    </apex:facet>
</apex:actionStatus> -->



</apex:pageBlockButtons>
</apex:pageBlock>
 

In below report for account my total quote count should be 5(unique quote dates in a opportunity ) not 6 ,1,2,3 are from same opp with diff quote date,4 and 5 are with same quote date on single opportunity,6th is for single opp -single quote so my total quote count should be 5 .How to make this unique calculation based on quote date grouped by account.

User-added image
ApexClass::::
public class ActiveContactEditController{

    public Id recordTypeId{get;set;}
    public Id contactId{get;set;}
    public Contact con;
    public String profileName{get;set;}
    public Contact con1{get;set;}
    private ApexPages.StandardController sc;
    public Boolean editFlag{get; set;}
    public set<String> setOfUserPermissionSets{get;set;}
    public string mulId;
    public string mulId2;
    private List<sObject> duplicateRecords;
    private final Contact contact;
    public boolean hasDuplicateResult{get;set;}
    
    public boolean save_dup {get;set;}
    public boolean save_dup_ignore {get;set;}
    public boolean save_dup_ignorenew {get;set;}
    public boolean Test {get;set;}
        
    public ActiveContactEditController(ApexPages.StandardController controller){
    
    save_dup = false;
    save_dup_ignore = false;
    save_dup_ignorenew = false;
    Test = true;
    
     // Define the values for the contact you’re processing based on its ID
        Id id = ApexPages.currentPage().getParameters().get('id');
        this.contact = (id == null) ? new Contact() :
            [SELECT Id, FirstName, LastName
             FROM Contact WHERE Id = :id];
       
        // Initialize empty list of potential duplicate records
        this.duplicateRecords = new List<sObject>();
        this.hasDuplicateResult = false;
    
    
        this.sc = controller;
        con1 = new Contact();
       
         
        List<Schema.RecordTypeInfo> infos = Schema.SObjectType.Contact.RecordTypeInfos;
        Id defaultRecordTypeId;
        editFlag = false;
        //check each one
        for (Schema.RecordTypeInfo info : infos) {
          
          if (info.DefaultRecordTypeMapping) {
            
            defaultRecordTypeId = info.RecordTypeId;
            
            mulId = defaultRecordTypeId;
            mulId2 = mulId.substring(0,mulId.length()-3);
            
            system.debug('defaultRecordTypeId ' + mulId2);
          }
        }

        if(Apexpages.currentpage().getparameters().get('RecordType') != NULL){
        
            recordTypeId = Apexpages.currentpage().getparameters().get('RecordType');
            system.debug('******* recordTypeId ******  ' + recordTypeId );
           
            if(String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID))
            con1.Active__c = true;
            
            if(String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID))
            con1.Small_Market__c = true;
         
            
        }
        if(Apexpages.currentpage().getparameters().get('Id') != NULL){
        
            contactId = Apexpages.currentpage().getparameters().get('Id');
            system.debug('contactId ' + contactId );
            con = [SELECT RecordtypeId from contact where id =: contactId];
            recordTypeId = con.RecordtypeId;
            
           
            
            if(contactId != null)
            editFlag = true;
        }
        if(recordTypeId == NULL){
        
            //recordTypeId = defaultRecordTypeId;
            recordTypeId  = String.valueOf(mulId2) ;
            system.debug('testing mulid '+recordTypeId  );
            system.debug('testing mulid '+mulId2);
            con1.Active__c = true;
            con1.Customer_Type__c = 'Active-Primary';
            con1.Input_Type__c = 'Manual';
            system.debug('con1.Customer_Type__c'+con1.Customer_Type__c);
            system.debug('con1.Input_Type__c'+con1.Input_Type__c);
        }
        
    }
    
    
    public List<sObject> getDuplicateRecords() {
        return this.duplicateRecords;
    }
 
    public boolean getRedirect(){
 
        if((recordTypeId != Label.Active_RecordTypeID || recordTypeId != Label.SM_Customer_RecordTypeID) && contactId == NULL){
        
            return true;
        }
        else{
        
            return false;
        }
    }
    
    public PageReference nextPage(){
    
        String ContactName;
        String relatedToFieldId = 'CF'+Label.Related_to_field_id+'_lkid';
        Id parentId = Apexpages.currentpage().getparameters().get(relatedToFieldId);
        if(parentId!= NULL){
        Contact conObj = [SELECT Salutation,FirstName,MiddleName, LastName from Contact where id =: parentId];
         /*** Forming Contact fullname  to use in URL ***/                  
         String Salutation = '';
         String FirstName = '';
         String MiddleName = '';
         String LastName = '';
         
         if(conObj.Salutation != NULL )
          Salutation = conObj.Salutation + '+';
         
         if(conObj.FirstName != NULL )
          FirstName = conObj.FirstName + '+';
        
         if(conObj.MiddleName != NULL )
          MiddleName = conObj.MiddleName + '+';
          
          LastName = conobj.LastName;
          
          ContactName = Salutation + FirstName + MiddleName + LastName;
         }
        system.debug('recordTypeId '+ recordTypeId );
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        if(recordTypeId != NULL && parentId != NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID) ) && !String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId) && contactId == NULL){
        
            system.debug('Error1');
            PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&CF'+Label.Related_to_field_id+'='
              +ContactName+'&'+relatedToFieldId+'='+parentId + '&nooverride=1');

            return pRef;
        }
        
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        else if(recordTypeId!= NULL && parentId == NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)) && !String.valueOf(mulId2).contains(Label.Active_Retiree_RecordTypeId) && contactId == NULL){
          system.debug('Error2 ' + recordTypeId);
         
          PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&nooverride=1');
          
          return pRef;
        }
        
        // Added '!String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)' for small Market Wave 1
        if(contactId != NULL && (!String.valueOf(recordTypeId).contains(Label.Active_RecordTypeID) && !String.valueOf(recordTypeId).contains(Label.SM_Customer_RecordTypeID)) && !String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId)){
         system.debug('Error3');
            PageReference pRef = new PageReference('/'+contactId+'/e?&nooverride=1'+'%2F'+contactId+'&retURL='+contactId);
            return pRef;
        }
        else if(contactId != NULL && String.valueOf(recordTypeId).contains(Label.Active_Retiree_RecordTypeId) && (setOfUserPermissionSets.contains('MM_Read_Only') || setOfUserPermissionSets.contains('MM_RET_Account_Manager') || setOfUserPermissionSets.contains('MM_RET_BC') || setOfUserPermissionSets.contains('MM_RET_Claims_Analyst') || setOfUserPermissionSets.contains('MM_RET_Claims_Manager') || setOfUserPermissionSets.contains('MM_RET_Manager') || setOfUserPermissionSets.contains('MM_RET_Quality_Assurance') || setOfUserPermissionSets.contains('MM_RET_Team_Lead') || setOfUserPermissionSets.contains('MM_SM_OSD'))){
         system.debug('Error4');
            PageReference pRef = new PageReference('/'+contactId+'/e?&nooverride=1&retURL=/'+contactId);
            return pRef;
        }
        else if(contactId == NULL && String.valueOf(mulId).contains(Label.Active_Retiree_RecordTypeId) && (setOfUserPermissionSets.contains('MM_Read_Only') || setOfUserPermissionSets.contains('MM_RET_Account_Manager') || setOfUserPermissionSets.contains('MM_RET_BC') || setOfUserPermissionSets.contains('MM_RET_Claims_Analyst') || setOfUserPermissionSets.contains('MM_RET_Claims_Manager') || setOfUserPermissionSets.contains('MM_RET_Manager') || setOfUserPermissionSets.contains('MM_RET_Quality_Assurance') || setOfUserPermissionSets.contains('MM_RET_Team_Lead') || setOfUserPermissionSets.contains('MM_SM_OSD'))){
         system.debug('Error5');
            PageReference pRef = new PageReference('/003/e?RecordType='+recordTypeId+'&nooverride=1&retURL=/003/o');
            return pRef;
        }
        else{
         system.debug('Error6');
            return NULL;
        }
    }

    public boolean validateDobandsocial(Contact conObj){
        Id acctId =conObj.AccountId;
        Date birthDt= conObj.DOB__c;
        String ssn = conObj.Social_Security_Number__c;
        Account accObj = [SELECT Id,Small_Market__c,Active__c,Client_Type__c from Account where id =: acctId];
        If (accObj.Active__c && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))){
            return false;
        }else if (accObj.Small_Market__c && accObj.Client_Type__c != 'Brokerage' && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))) {
            return false;
        }else if (accObj.Small_Market__c && accObj.Client_Type__c == 'Brokerage' && (String.isBlank(String.valueOf(conObj.DOB__c)) || String.isBlank(conObj.Social_Security_Number__c))) {
            return true;
        }else {
            return true;
        }

     }

    public pageReference Test(){
      hasDuplicateResult = false ;  
    Boolean stayOnpage = false;
    Contact conObj =(Contact) sc.getRecord();    
    boolean validateResult =  validateDobandsocial(conObj);
     try{
        if(validateResult){
            if(contactId == NULL){
                stayOnpage = Test2(conObj);
               // insert conObj;
                }
            else{
               // stayOnpage = Test2(conObj);          
                update conObj;
               }
      
       if(stayOnPage == true)
       {
        save_dup_ignore = true;
        save_dup = true;
        save_dup_ignorenew = true;

        Test = false;
        return null;
       }
       else{
              
        PageReference saveAndRedirectPage = new PageReference('/apex/ActiveContactEditRedirectPage');
        saveAndRedirectPage.setRedirect(true);
        saveAndRedirectPage.getParameters().put('id', conObj.id);
        saveAndRedirectPage.getParameters().put('name', conObj.name);
        return saveAndRedirectPage;}
       }else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'BirthDate and/or SSN can not be blank'));
            return null;
        }
    }catch(Exception ex){
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'testvali1'+ex.getdmlMessage(0)));
    return null;
    }
 
    }
    
    public Boolean Test2(Contact conObj){

    hasDuplicateResult = true ;
 
        Database.DMLOptions dml = new Database.DMLOptions();
        dml.DuplicateRuleHeader.allowSave = true;
        dml.DuplicateRuleHeader.runAsCurrentUser = true;
         //Contact conObj =(Contact) sc.getRecord();
         
        Database.SaveResult saveResult = Database.insert(conObj, false);
      
        system.debug('The Test Debug after contact save on  savedupe');
        
       
         if (!saveResult.isSuccess()) {
         system.debug('The Test Inside after success savedupe');
            for (Database.Error error : saveResult.getErrors()) {
                // If there are duplicates, an error occurs
                // Process only duplicates and not other errors
                //   (e.g., validation errors)
                if (error instanceof Database.DuplicateError) {
                    // Handle the duplicate error by first casting it as a
                    //   DuplicateError class
                    // This lets you use methods of that class
                    //  (e.g., getDuplicateResult())
                    Database.DuplicateError duplicateError =
                            (Database.DuplicateError)error;
                    Datacloud.DuplicateResult duplicateResult =
                            duplicateError.getDuplicateResult();
                    
                    // Display duplicate error message as defined in the duplicate rule
                    ApexPages.Message errorMessage = new ApexPages.Message(
                            ApexPages.Severity.ERROR, 'Duplicate Error: ' +
                            duplicateResult.getErrorMessage());
                    ApexPages.addMessage(errorMessage);
                    
                    // Get duplicate records
                    this.duplicateRecords = new List<sObject>();

                    // Return only match results of matching rules that
                    //  find duplicate records
                    Datacloud.MatchResult[] matchResults =
                            duplicateResult.getMatchResults();

                    // Just grab first match result (which contains the
                    //   duplicate record found and other match info)
                    Datacloud.MatchResult matchResult = matchResults[0];

                    Datacloud.MatchRecord[] matchRecords = matchResult.getMatchRecords();

                    // Add matched record to the duplicate records variable
                    for (Datacloud.MatchRecord matchRecord : matchRecords) {
                        System.debug('MatchRecord: ' + matchRecord.getRecord());
                        this.duplicateRecords.add(matchRecord.getRecord());
                    }
                    this.hasDuplicateResult = !this.duplicateRecords.isEmpty();
                }
            }
            
            //If there’s a duplicate record, stay on the page
            //return null;
            return (true);
        }
        
        /******* END *******/  
        else
        return (false);

    }

}


 
Hi i have two objects Account and Offer .On offer object i have two picklist fields using this two picklists i am showing/rendering  a table (vf component ) ,But now along with two picklist fields i have to render like this: Check the logged in user and under user there is a field called "See Headline as Partner" now i have to map this field value with account name in my org and under that  account i have a new text field called "product hierarchy " now i have to render the table based on already existed two picklists and this product hierarchy text field value.





 
Hii I have written a Code For Onclick Button Which has to disable after first click and has to call a method which converts lead in to Opportunity,Accounts and Contact..
Code:
{!REQUIRESCRIPT("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js")}
  var $ = jQuery.noConflict();
$(document).off('click', '.btn').on('click', '.btn',function(e) {
    $('input[name*=custom_convert]').attr('class', 'btnDisabled');
      $('input[name*=custom_convert]').attr('value','Converting...');
      
      console.log('*****clicked*********');
window.location='/apex/LeadConvertOverride?id={!Lead.Id}';
    });User-added image
 
Once you click on Convert button on lead page ,Its gets converted in to Oppurtinity,Account,Contact In Upfront or Redirects to Custom Lead conversion page Based on some fields missing.
Hii I had a Requirement where I have too avoid Creation of Multiple Accounts,Oppurtunities and Contact On Click Of Convert Button On  Stamdard Lead Page.
How To Disable the Standard Lead "Convert" Button On Click.

Hi Anything Wrong In My Trigger ,When I am Trying To Deploy a Test Class(In Test Class Ii am Just Inserting  Account,Oppurtunity,Cardapplication objcet) I am Getting This Below Error:
System.LimitException: Too many SOQL queries: 101 
Stack Trace: Trigger.UpdateEngagement: line 13, column 1
trigger UpdateEngagement on Opportunity (after insert, after update, before update) 
{
    if(Trigger.isInsert || (Trigger.isUpdate && Trigger.isAfter))
    {
        map<Id, string> mpOpp = new map<Id, string>();
        for(Opportunity o: Trigger.New)
        {
            mpOpp.put(o.AccountId, o.StageName);
        }
        
        If(mpOpp != null && mpOpp.size()>0)
        {
            List<Account> lstAcc = [select  EngagementCode__c, id from Account where id in :mpOpp.KeySet()];
            for(Account a: lstAcc)
            {
                a.EngagementCode__c = mpOpp.get(a.id);
            }
            update lstAcc;
        }
    }

    // New code added to Update the Incentive Options dependent field on stage change - by Vivek
 /*   if(Trigger.isUpdate && Trigger.isBefore)
    {
    
system.debug('@@1Before Incentive offer + Incentive'+Trigger.Old[0].Incentive__c);
        for(Opportunity OppNew : Trigger.New)
        {
            for(Opportunity OppOld : Trigger.Old)
            {
                if(OppNew.StageName != 'Product Recommendation' && OppOld.Incentive__c!='')
                {
                
system.debug('@@2Copying Incentive offer'+OppOld.Incentive__c);
                    OppNew.Incentive__c = OppOld.Incentive__c;
                }
            }
        }     
    } */
}
Hi I am Using Page Block Buttons Instead Of CommandButtons To Dispaly Buttons On Both Top and Bottom,I Have a Requirement where I have to Disable Button OnClick ,So We Can avoid Multiple Submissions.I Tried With PageBlock Buttons Disabling Is Working Fine But Onclick If any Button Either Top or Buttom i have to Disable Booth Buttoms...Any Ideas Plz...??? TIA.


<apex:pageBlock title="Test" id="pgblk">

<apex:pageMessages />

<apex:pageBlockButtons >
<apex:commandButton action="{!cancel}" value="Cancel"/>
<!--<apex:commandButton value="Convert" id="Convert"  action="{!convertLeadFunction}" />-->
<apex:commandButton value="Convert" action="{!convertLeadFunction}" onclick="disable" reRender="pgblk"/>


<!--<apex:commandButton value="Convert" action="{!convertLeadFunction}" onclick="alert('Please Wait Until Lead Gets Converted');"  /> -->

<!--<apex:actionStatus id="saveStatus">
    <apex:facet name="stop">
        <apex:commandButton value="Convert" action="{!convertLeadFunction}" status="saveStatus" rerender="saveParentBlock" />
    </apex:facet>
    <apex:facet name="start">
        <apex:commandButton value="Please Wait While Converting" disabled="true" status="saveStatus" rerender="saveParentBlock" />
    </apex:facet>
</apex:actionStatus> -->



</apex:pageBlockButtons>
</apex:pageBlock>