You need to sign in to do that
Don't have an account?
Ashley Kabakci
IF statement formula help - getting an error
I am trying to do the following:
On a contact record, if the Mobile Phone field is not blank, use it to populate the Phone in Use field on the same contact record. If the Mobile Phone field is blank, then use the Work Phone field to populate the Phone in Use field. If the Work Phone field is blank, then use the Home Phone field to populate the Phone in Use field. If the Home Phone field is blank, then use Other Phone field to populate the Phone in Use field. If the Other Phone field is blank, the Phone in use field remains blank.
I created the formula below, but I am getting an error I don't know how to fix: "Error: Incorrect parameter type for function 'IF()'. Expected Boolean, received Text"
IF(NOT(ISBLANK(MobilePhone)), Phone_In_Use__c = MobilePhone,
IF (NOT(ISBLANK(npe01__WorkPhone__c)), Phone_In_Use__c = npe01__WorkPhone__c,
IF (NOT(ISBLANK(HomePhone)), Phone_In_Use__c = HomePhone,
IF (NOT(ISBLANK(OtherPhone)), Phone_In_Use__c = OtherPhone,
" "
))))
On a contact record, if the Mobile Phone field is not blank, use it to populate the Phone in Use field on the same contact record. If the Mobile Phone field is blank, then use the Work Phone field to populate the Phone in Use field. If the Work Phone field is blank, then use the Home Phone field to populate the Phone in Use field. If the Home Phone field is blank, then use Other Phone field to populate the Phone in Use field. If the Other Phone field is blank, the Phone in use field remains blank.
I created the formula below, but I am getting an error I don't know how to fix: "Error: Incorrect parameter type for function 'IF()'. Expected Boolean, received Text"
IF(NOT(ISBLANK(MobilePhone)), Phone_In_Use__c = MobilePhone,
IF (NOT(ISBLANK(npe01__WorkPhone__c)), Phone_In_Use__c = npe01__WorkPhone__c,
IF (NOT(ISBLANK(HomePhone)), Phone_In_Use__c = HomePhone,
IF (NOT(ISBLANK(OtherPhone)), Phone_In_Use__c = OtherPhone,
" "
))))
try with below formula,
Refer the below link formula fuctions with an examples
https://developer.salesforce.com/docs/atlas.en-us.usefulFormulaFields.meta/usefulFormulaFields/customize_functions.htm
If this helps, Please mark it as best answer.
Thanks!!
List<Contact> con = [Select Id, Name, MobilePhone, TestPhoneContact__c from Contact];
for(Contact cc:con){
// #1. This piece of code will help you with if the Mobile Phone field is not blank, use it to populate the Phone in Use field on the same
// contact record
if(cc.MobilePhone !='') {
cc.MobilePhone = cc.TestPhoneContact__c;
}}
// #2. If the Mobile Phone field is blank, then use the Work Phone field to populate the Phone_in_Use__c field.
if((isBlank(MobilePhone)){
Work_Phone__c = Phone_In_Use__c;
}
// #3. If the Work Phone field is blank, then use the Home Phone field to populate the Phone_in_Use__c field.
if((isBlank(MobilePhone) && (Work_Phone__c))){
Home_Phone__c = Phone_In_Use__c;
}
// #4. If the Home Phone field is blank, then use Other Phone field to populate the Phone_in_Use__c field.
if((isBlank(MobilePhone) && (Work_Phone__c)) && (Home_Phone__c)){
Other_Phone__c = Phone_In_Use__c;
}
// #5. If the Other Phone field is blank, the Phone_in_use__c field remains blank.
if((isBlank(MobilePhone) && (Work_Phone__c)) && (Home_Phone__c) && (Other_Phone__c)){
Other_Phone__c = Phone_In_Use;
}
}
// Note: from point number 2 until #5 you have to factor the previous fields that were mentioned blank too.
Hope this helps