function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ryan Mastbergen 4Ryan Mastbergen 4 

Checkbox Formula - Incorrect number of parameters for function

Hello Salesforce community!

I am having issues with the below formula checkbox to validate.  I am receiving the error 'Incorrect number of parameters for function 'IF()'. Expected 3, received 4'.  It has to be something silly such as a misplaced bracket - Any help would be greatly appreciated!
 
/* If the override is checked, this field should be true */
IF( Marketing_Cloud_Sync_Override__c = True, True,

/* If the unSync is checked, this field should be false */
IF( Marketing_Cloud_unSync_Override__c  = True, False,

/* For Member Contacts, if they are 18 or above and the status is set to active, this field should be true */
IF( RecordType.DeveloperName = "Member" &&
    FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
    ISPICKVAL(Contact_Status__c , "Active"),True,False,

/* For Lead Contacts, if they are 18 or above, email is not blank, the contact is less than a year old, this field should be true */
IF( RecordType.DeveloperName = "Lead" &&
    FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
    (NOT ISBlank(Email)) &&
    (TODAY()-DATEVALUE(CreatedDate)<= 365),True,False,

/* For Group Contacts, if the email is not blank, this should should be true */
IF( RecordType.DeveloperName = "Group_Contact" &&
   (NOT ISBlank(Email)),True,False,False)))))

 
Best Answer chosen by Ryan Mastbergen 4
Andrew GAndrew G
Your issue is in the 3rd, 4th and 5th elements.  Although it is probably the 3rd element that is throwing the actual error.
You have 4 x elements in each of those.  I would read it as each has an extra False
I find that fomating the formula often helps with finding these types of errors:
/* If the override is checked, this field should be true */
IF( Marketing_Cloud_Sync_Override__c = True, 
  True,

  /* If the unSync is checked, this field should be false */
  IF( Marketing_Cloud_unSync_Override__c  = True, 
    False,

    /* For Member Contacts, if they are 18 or above and the status is set to active, this field should be true */
    IF( RecordType.DeveloperName = "Member" &&
      FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
      ISPICKVAL(Contact_Status__c , "Active"),
      True,

      /* For Lead Contacts, if they are 18 or above, email is not blank, the contact is less than a year old, this field should be true */
      IF( RecordType.DeveloperName = "Lead" &&
        FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
        (NOT ISBlank(Email)) &&
        (TODAY()-DATEVALUE(CreatedDate)<= 365),
        True,

        /* For Group Contacts, if the email is not blank, this should should be true */
        IF( RecordType.DeveloperName = "Group_Contact" &&
          (NOT ISBlank(Email)),
          True,
          False
        )
      )
    )
  )
)

I would check to see if I have interpreted your logic correctly

regards

Andrew
 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Ryan,

>> https://salesforce.stackexchange.com/questions/267973/error-incorrect-number-of-parameters-for-function-if-expected-3-received

As mentioned in the above forum thread as mentioned can you try checking if Your parentheses are in the wrong places? The AND function should have two parameters each. The compiler is seeing IF(AND(...), ..., True, IF(...; 

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Andrew GAndrew G
Your issue is in the 3rd, 4th and 5th elements.  Although it is probably the 3rd element that is throwing the actual error.
You have 4 x elements in each of those.  I would read it as each has an extra False
I find that fomating the formula often helps with finding these types of errors:
/* If the override is checked, this field should be true */
IF( Marketing_Cloud_Sync_Override__c = True, 
  True,

  /* If the unSync is checked, this field should be false */
  IF( Marketing_Cloud_unSync_Override__c  = True, 
    False,

    /* For Member Contacts, if they are 18 or above and the status is set to active, this field should be true */
    IF( RecordType.DeveloperName = "Member" &&
      FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
      ISPICKVAL(Contact_Status__c , "Active"),
      True,

      /* For Lead Contacts, if they are 18 or above, email is not blank, the contact is less than a year old, this field should be true */
      IF( RecordType.DeveloperName = "Lead" &&
        FLOOR((TODAY()-Birthdate)/365.2425) >= 18 &&
        (NOT ISBlank(Email)) &&
        (TODAY()-DATEVALUE(CreatedDate)<= 365),
        True,

        /* For Group Contacts, if the email is not blank, this should should be true */
        IF( RecordType.DeveloperName = "Group_Contact" &&
          (NOT ISBlank(Email)),
          True,
          False
        )
      )
    )
  )
)

I would check to see if I have interpreted your logic correctly

regards

Andrew
 
This was selected as the best answer
Ryan Mastbergen 4Ryan Mastbergen 4
You are the man Andrew - Thanks!!