Tip 1: Put Every Function on a Separate Line
Place each function on its own line makes the formula easier to read and troubleshoot.
IF(AND(ISBLANK(myDate_c),active_c=true),"Missing Date","Not Applicable")
IF(
AND(
ISBLANK(myDate_c),
active_c=true
),
"Missing Date",
"Not Applicable"
)
Tip 2: Indent Sections Within Parentheses
When your formula involves multiple functions, indentation helps visually isolate each function and makes it easier to identify errors, such as misplaced characters.
In this example, with indentation, you see that the bulk of the formula sits within a single IF statement and that the AND statement contains two functions. Inside the AND statement, the function ISBLANK is enclosed in parentheses.
IF(
AND(
ISBLANK(myDate_c),
active_c=true
),
"Missing Date",
"Not Applicable"
)
Indentation can also help you zero in on mistakes.
IF(
AND(
ISBLANK(myDate_c)
),
active_c=true
),
"Missing Date",
"Not Applicable"
)
The indented layout makes it easy see the formula’s structure. You can quickly find and remove the extra character so that the AND statement is correctly formatted.
IF(
AND(
ISBLANK(myDate_c)
),
active_c=true
),
"Missing Date",
"Not Applicable"
)
Tip 3: Write Statement and Function Names in Uppercase
All the examples here use uppercase letters for statement and function names, such as IF, AND, and ISBLANK.
Tip 4: Handle Null and Required Input Field Values
These examples reference a field called myDate__c and use the ISBLANK check to confirm that the field is populated. It’s important to verify the contents of any field in a formula. Without this verification, a formula can fail.
IF(
AND(
ISBLANK(myDate__c),
ISBLANK(mySecondDate__c),
active__c=true,
mySecondDate__c > myDate__c
),
"Missing Date",
"Not Applicable"
)
No comments:
Post a Comment