• Tushar Khorate
  • NEWBIE
  • 75 Points
  • Member since 2020
  • Salesforce Developer
  • Tech Mahindra

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 9
    Replies
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!
Are you looking for this formula: 
 Finding the Number of Business Days Between Two Dates.
Use this formula:
(5 * ( FLOOR( ( DATEVALUE( Date_of_Joining__c) - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( DATEVALUE(Date_of_Joining__c) - DATE( 1900, 1, 8), 7 ) ) ) - (5 * ( FLOOR( ( DATEVALUE(CreatedDate) - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( DATEVALUE(CreatedDate) - DATE( 1900, 1, 8), 7 ) ) )
 (Use your date fields instead of Date_of_Joining__c)
If you found this is helpful, Like this solution so that others are also see this. 
Would like to create a Tab to be able to remove Related Lists from "Details" tab. It is way too busy. TIA
I'm facing an error on my Trailhead account. My certifications aren't appearing, and the error below occurs when I try to connect my web assessor account. Could you please help? Thanks,
User-added image
Whole Scenario is, i have to take one Custom field in standard object CONTACT named "NumberOfOpportunities". And need to display number of opportunities related to particular contact in this custom field.
Hello,

I am trying to login to the Developer Workbench and keep getting the following error:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Any ideas what could be causing this?

Blessings,
Kees

 
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!
Hi All,

I want to display number of contacts associated with an account using triggers.

for this I had created a lookup field like noofcontacts__c in account  object. and Wrote code as

trigger numberofcontacts on contact(after insert, after update, after delete) {
    Map<Id, List<Contact>> AcctContactList = new Map<Id, List<Contact>>();
    Set<Id> AcctIds = new Set<Id>();   
    List<schema.Account> AcctList = new List<schema.Account>();
    List<schema.Contact> ConList = new List<schema.Contact>();
   
    if(trigger.isInsert || trigger.isUPdate) {
        for(Contact Con : trigger.New) {
            if(String.isNotBlank(Con.AccountId)){
                AcctIds.add(Con.AccountId); 
            }  
        } 
    }
   
    if(trigger.isDelete) {
        for(Contact Con : trigger.Old) {
            AcctIds.add(Con.AccountId);    
        } 
    }          
   
    if(AcctIds.size() > 0){
        ConList = [SELECT Id, AccountId FROM Contact WHERE AccountId IN : AcctIds];
       
        for(Contact Con : ConList) {
            if(!AcctContactList.containsKey(Con.AccountId)){
                AcctContactList.put(Con.AccountId, new List<Contact>());
            }
            AcctContactList.get(Con.AccountId).add(Con);     
        }                          
      
           
        AcctList = [SELECT noofContacts__c FROM Account WHERE Id IN : AcctIds];
        for(Account Acc : AcctList) {
            List<schema.Contact> ContList = new List<schema.Contact>();
            ContList = AcctContactList.get(Acc.Id);
            Acc.Number_of_Contacts__c = ContList.size();
        }   
       
      
        update AcctList;   
    }

}
 I am   getting an error as "Variable doesnot exist:id".

Kindly support and suggest.

Thanks
The following formula will calculate the number of working days (inclusive) between 2 dates. A working day is defined as Monday to Friday. Even if the start or end dates are a weekend, these are accommodated.

IF(AND((5 - (CASE(MOD( Start_Date__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( End_Date__c  -   Start_Date__c ) + 1) < 7)),
((CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( End_Date__c  -  Start_Date__c ) - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))


The Start Date and End Date fields are custom in the above example and can be replaced as required. If use of a DateTime field is required then the DATEVALUE function will be required.

I also recommend a simple field validation rule is added to check that the End Date is after the Start Date.
  • January 05, 2009
  • Like
  • 9
Whole Scenario is, i have to take one Custom field in standard object CONTACT named "NumberOfOpportunities". And need to display number of opportunities related to particular contact in this custom field.
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!