• KN NJ
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

I have set Default value for a Picklist, but to my luck it is not working, don't know the reason for the same.

Can anyone help me with any workaround? Even Custom Picklists are not working with default values on Account. Although it is working for Contact. 

Default Value:
User-added image

New Account Page:
User-added image
 

How can I update the fields below on the Account object? I am not familiar with writing a Batch Trigger. Please see code below.

Number_of_Contacts__c​
Number_of_Active_Contacts__c

 
trigger NumberOfContacts on Account (before insert, before update) {
    if(trigger.isinsert)
        for(account a:trigger.new)
            a.Number_of_contacts__c = 0;
    else
        for(account a:[select id,(select id from contacts) from account where id in :trigger.new])
            trigger.newmap.get(a.id).Number_of_contacts__c = a.contacts.size();
            
        for(account b:[select id,(select id from contacts where Inactive__c = False) from account where id in :trigger.new])
            trigger.newmap.get(b.id).Number_of_active_contacts__c = b.contacts.size();
}

Thanks in advnce! 
Anyone else having trouble connecting to the UpWork group for Salesforce.com? I've tried everything and can't get past the screen to start a dev. org. and submit my application. *sigh*