Newer Version Available

This content describes an older version of this product. View Latest

Try It Out: Define a “Days Open” Custom Formula Field

We'll begin building the formula field the same way we created our other custom fields.
  1. From the Positions tab, click Quick access menu icon to open the quick access menu (if it isn't open already).
  2. Hover over View Fields and click New.
    Opening the New Custom Field Wizard from the Quick Access Menu The quick access menu, with the New field link highlighted
  3. Select the Formula data type, and click Next.

Step 2 of the New Custom Field wizard appears.

Custom Formula Field Wizard Step 2 Step 2 of the Custom Formula Field wizard
  1. In the Field Label field, enter Days Open. Field Name is populated automatically.
  2. Select the Number formula return type.

In this case, even though we're subtracting Date fields, we want to end up with just a regular numeric value.

  1. Change the Decimal Places value to 0, and click Next.

Now it's time to enter the details of our formula.

  1. Click the Advanced Formula tab, as shown in the following screenshot.
Custom Formula Field Editor The Custom Formula Field editor

We want to use the Advanced Formula tab so we can access the platform's built-in functions through the Functions list on the right side.

  1. From the Functions list, double-click IF.

Our formula now looks like this:

1IF(logical_test, value_if_true, value_if_false)

Let's go ahead and define the logical test:

  1. Delete logical_test from the formula, but leave your cursor there.
  2. From the Functions list, double-click ISBLANK.
  3. Delete expression from the ISBLANK function you just inserted, but leave your cursor there.
  4. Click the Insert Field button. Two columns appear in an overlay.
  5. In the left column, select Position.
  6. In the right column, select Close Date.
  7. Click Insert.

Did you notice that you didn't have to remember to use the API name of the Close Date field? The platform remembered for you when it inserted the value. Our formula now looks like this:

1IF( ISBLANK( Close_Date__c ) , value_if_true, value_if_false)

Now, let's specify the value if our logical test evaluates to true:

  1. Delete value_if_true from the formula, but leave your cursor there.
  2. Press ENTER on your keyboard, and space over 10 spaces.

Adding the carriage return and spaces makes our formula more legible for others.

  1. From the Functions list, double-click TODAY.
  2. Click the Insert Operator button and choose Subtract.
  3. Click the Insert Field button.
  4. In the left column, select Position.
  5. In the right column, select Open Date.
  6. Click Insert.

We're getting closer—our formula now looks like this:

1IF( ISBLANK( Close_Date__c ) ,
2          TODAY()  -  Open_Date__c , value_if_false)

Finally, let's specify the value if our logical test evaluates to false:

  1. Delete value_if_false from the formula, but leave your cursor there.
  2. Press ENTER on your keyboard, and space over 10 spaces.
  3. Click the Insert Field button.
  4. In the left column, select Position.
  5. In the right column, select Close Date and click Insert.
  6. Click Insert Operator and choose Subtract.
  7. Click the Insert Field button.
  8. In the left column, select Position.
  9. In the right column, select Open Date and click Insert.

Our formula now matches our original:

1IF( ISBLANK( Close_Date__c ) ,
2          TODAY()  -  Open_Date__c ,
3          Close_Date__c  -  Open_Date__c )

Now that we've gone through those steps of the procedure, note that we could have just typed in the formula that we figured out in the last section. However, using the formula editor is a lot easier because you don't have to remember function syntax or API names of fields and objects. Let's keep going and finish up this field:

  1. Click Check Syntax to check your formula for errors.
  2. Select Treat blank fields as blanks, and click Next.
  3. Accept all remaining field-level security and page layout defaults.
  4. Click Save.
  5. On the Positions Fields page, scroll down to the Positions Custom Fields & Relationships section.
  6. Click Edit next to the new Days Open field.
  7. In the Description text box, enter The number of days a position has been (or was) open.
  8. Add an optional Help Text description if you wish.
  9. Click Save.