Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
brianwhi

# If...Then Help Needed

Hello,

I'm trying to create an if...then function based on the following:

- If EMAIL is blank, move EMAIL2 to NEW FIELD
- If EMAIL and EMAIL2 are blank, move EMAILFWDADDRESS to NEW FIELD

I've gotten the two forumlas to work separately but can't figure out how to combine them into one long formula.

IF( LEN (Email) =0 ,  Email_2__c , Email)

IF(AND (LEN (Email)=0, LEN (Email_2__c)=0), emailfwdaddress__c , Email)

Can anyone offer any help?

Thanks!
Jakester
It's late, so I'm pretty sure there's a cleaner way to do this, but I think this would do the trick:

Code:
```if(LEN (Email_2__c)=0,
if(LEN (Email) =0 ,  Email_2__c,
if(AND (LEN (Email)=0, LEN (Email_2__c)=0), emailfwdaddress__c , Email)
)
)

```

brianwhi
Thanks for the feedback, Jakester.

I got the following error message:
`Error: Incorrect number of parameters for function IF(). Expected 3, received 2`

Jakester

I think all that's missing is what you'd what to do if Email_2__c is not blank, which you would put after the second-to-last close parenthesis:

Code:
```if(LEN (Email_2__c)=0,
if(LEN (Email) =0 ,  Email_2__c,
if(AND (LEN (Email)=0, LEN (Email_2__c)=0), emailfwdaddress__c , Email)
), [enter the field you want to show if Email_2__c is not blank]
)
```

brianwhi
I didn't get any error messages, but when both Email and Email2 are blank it doesn't populate the new field with EmailFwdAddress.

Jakester
Yeah, I kinda thought you wouldn't like the results there... ok, let's try this again:

Code:
```if(AND (LEN (Email)=0, LEN (Email_2__c)=0), emailfwdaddress__c ,
if(LEN (Email) =0 ,  Email_2__c, Email)
)
```

brianwhi
That did it!  Thanks a million. I don't think I ever would've figured that out on my own.
Jakester
Sweet! You're very welcome.