• Sandhya K 10
  • NEWBIE
  • 40 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
Hi ,

I have a created a simple VF page
<apex:page standardController="Delivery__c" sidebar="false" >
<apex:relatedList list="Addresses__r"/>
</apex:page>
Now I have added this VF page to a section on a custom Object : Delivery__c details pagelayout . And is shown as expected.
VF page added in a section of page layout
But the problem is when i click on New Address , it opens in the section  and not in a new window.
User-added image
 Is there a way that I can override the New ​Address button and navigate it to another VF page or open in a new window ?
What is Javascript Closure ? How can we use that in a VF page ? An example of the same would be very helpful . 
I have a custom Object Book3__c , In which I have the records as Below.

Name          Email__c
Book1    hh@gmail.com
Book2    hh@gmail.com

Book3    gg@gmail.com
Book4    gg@gmail.com

Book5    kk@gmail.com
Book6    kk@gmail.com
Book7    kk@gmail.com

The problem with the below code is, It deletes all the records . But I need to Keep one and delete the remaining. What Am I missing here.?
 
Global class removeDuplicateRecords implements Database.Batchable<SObject> , Database.Stateful {
    
    global Set<String> emailstring;
    
    global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator([Select Email__c from Book3__c where Email__c != null]);
      }
    
    global void execute(Database.BatchableContext BC , List<Book3__c> scope){
        
        Set<String> emailstring = new Set<String>();
        
      //  Map<String , Book3__c> EmailBookmap = new Map<String , Book3__c>();
        for(Book3__c s : scope){
        // EmailBookmap.put(s.Email__c , s);
            emailstring.add(s.Email__c);
            
        }  
       // system.debug(EmailBookmap);
        system.debug(emailstring);
        
        List<Book3__c> bklst = [select Email__c from Book3__c where Email__c In :emailstring ];
        
        List<Book3__c> duplicatelist = new List<Book3__c>();
        
        for(Book3__c bk : Scope){
        for(Book3__c b :bklst){
           // if(emailstring.contains(b.Email__c)){
            if(bk.email__c == b.email__c){
              duplicatelist.add(b);  
            }
            else{
             emailstring.add(bk.Email__c);   
            }
        }
        }
        
       // system.debug(EmailBookmap);
        system.debug(duplicatelist);
      delete duplicatelist;
    }
    
    global void finish(Database.BatchableContext BC){
        
    }
        

}

 
I have Created a field email__c on Account and I want to update Update this with the contact that is Active (Active__c checkbox on Contact)
When contact status is active, then I want to deactivate all related account contacts and update active contact email on account email filed . How do I achieve this. I am not knowing how do I deactivate the remaining contacts if the current contact is Active. Please guide me in SOlving this
public class updateAccwithActiveContactEmail {

    public Static void updateAccountwithActiveContact(List<Contact> newconlist){
        
        List<Account> accToUpdate = new List<Account>();
        List<Contact> conToUpdate = new List<Contact>();
       
        Set<Id> accIdSet = new Set<Id>();
        for(Contact c : newconlist){
         accIdSet.add(c.AccountId);   
        }
        system.debug(accIdSet);
        
       List<Account> accWithConlist = [Select Id,Email__c,(Select Id,Active__c,Email,AccountId from Contacts) from Account Where Id IN : accIdSet];
       List<Contact> conlist = accWithConlist[0].Contacts;
        system.debug(accWithConlist);
       system.debug(conlist); 
        system.debug(newconlist);
        
        for(Contact c : newconlist){
         for(Account a : accWithConlist ){
             for(Contact con :conlist ){
                   // if(c.Id == con.Id && c.Active__c == true){
                    if(c.Id != con.Id ){
                    con.Active__c = False ;
                    con.Account.Email__c = c.Email;
                    }
                   
                    
                // accToUpdate.add(a);
                conToUpdate.add(con);
                   // system.debug(accToUpdate);
                    system.debug(conToUpdate);
               }
             // update accToUpdate;  
            }
        }
     }
}

 
What are the main differences between meta data and custom metadata ?
I am using StandardController="Emploee__c" , able to retrieve the input text , while unable to retrieve the value in textarea.What would be the problem ? And how do i retrieve it. My requirement is I want to use the textarea tag only.

The field i have in salesforce is long textarea

Note : I am able to save the value I entered in the text Area , but value not retrieved on my VF Page as it did for input text , when I give the Id in the URL. 
Name : <input type="text" value="{!Emploee__c.Name}" id="nm"/>
<textarea id="resizable" rows="5" cols="20" value="{!Emploee__c.Long_Description__c}" ></textarea>

<button onclick="save();" >Submit Form </button>

User-added image
How to retrieve value in text area when I give Id in the url.
 
I tried deactivating a picklist value and activating it by clicking the Activate in inactive values section as shown in the image. The value reappeared as expected . Why do we need to recreate a picklist value to reactivate it ? Cant we reactivate it by clicking the Activate near the Inactive value ??

Can't we activate using this Activate ?
 
Hi ,

I have a created a simple VF page
<apex:page standardController="Delivery__c" sidebar="false" >
<apex:relatedList list="Addresses__r"/>
</apex:page>
Now I have added this VF page to a section on a custom Object : Delivery__c details pagelayout . And is shown as expected.
VF page added in a section of page layout
But the problem is when i click on New Address , it opens in the section  and not in a new window.
User-added image
 Is there a way that I can override the New ​Address button and navigate it to another VF page or open in a new window ?
I have a custom Object Book3__c , In which I have the records as Below.

Name          Email__c
Book1    hh@gmail.com
Book2    hh@gmail.com

Book3    gg@gmail.com
Book4    gg@gmail.com

Book5    kk@gmail.com
Book6    kk@gmail.com
Book7    kk@gmail.com

The problem with the below code is, It deletes all the records . But I need to Keep one and delete the remaining. What Am I missing here.?
 
Global class removeDuplicateRecords implements Database.Batchable<SObject> , Database.Stateful {
    
    global Set<String> emailstring;
    
    global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator([Select Email__c from Book3__c where Email__c != null]);
      }
    
    global void execute(Database.BatchableContext BC , List<Book3__c> scope){
        
        Set<String> emailstring = new Set<String>();
        
      //  Map<String , Book3__c> EmailBookmap = new Map<String , Book3__c>();
        for(Book3__c s : scope){
        // EmailBookmap.put(s.Email__c , s);
            emailstring.add(s.Email__c);
            
        }  
       // system.debug(EmailBookmap);
        system.debug(emailstring);
        
        List<Book3__c> bklst = [select Email__c from Book3__c where Email__c In :emailstring ];
        
        List<Book3__c> duplicatelist = new List<Book3__c>();
        
        for(Book3__c bk : Scope){
        for(Book3__c b :bklst){
           // if(emailstring.contains(b.Email__c)){
            if(bk.email__c == b.email__c){
              duplicatelist.add(b);  
            }
            else{
             emailstring.add(bk.Email__c);   
            }
        }
        }
        
       // system.debug(EmailBookmap);
        system.debug(duplicatelist);
      delete duplicatelist;
    }
    
    global void finish(Database.BatchableContext BC){
        
    }
        

}

 
I have Created a field email__c on Account and I want to update Update this with the contact that is Active (Active__c checkbox on Contact)
When contact status is active, then I want to deactivate all related account contacts and update active contact email on account email filed . How do I achieve this. I am not knowing how do I deactivate the remaining contacts if the current contact is Active. Please guide me in SOlving this
public class updateAccwithActiveContactEmail {

    public Static void updateAccountwithActiveContact(List<Contact> newconlist){
        
        List<Account> accToUpdate = new List<Account>();
        List<Contact> conToUpdate = new List<Contact>();
       
        Set<Id> accIdSet = new Set<Id>();
        for(Contact c : newconlist){
         accIdSet.add(c.AccountId);   
        }
        system.debug(accIdSet);
        
       List<Account> accWithConlist = [Select Id,Email__c,(Select Id,Active__c,Email,AccountId from Contacts) from Account Where Id IN : accIdSet];
       List<Contact> conlist = accWithConlist[0].Contacts;
        system.debug(accWithConlist);
       system.debug(conlist); 
        system.debug(newconlist);
        
        for(Contact c : newconlist){
         for(Account a : accWithConlist ){
             for(Contact con :conlist ){
                   // if(c.Id == con.Id && c.Active__c == true){
                    if(c.Id != con.Id ){
                    con.Active__c = False ;
                    con.Account.Email__c = c.Email;
                    }
                   
                    
                // accToUpdate.add(a);
                conToUpdate.add(con);
                   // system.debug(accToUpdate);
                    system.debug(conToUpdate);
               }
             // update accToUpdate;  
            }
        }
     }
}

 
I tried deactivating a picklist value and activating it by clicking the Activate in inactive values section as shown in the image. The value reappeared as expected . Why do we need to recreate a picklist value to reactivate it ? Cant we reactivate it by clicking the Activate near the Inactive value ??

Can't we activate using this Activate ?