,

Formula Fields for Calculation

Your first use of formula fields tracks the age of a Position posting with a simple calculation.

1.
Return to the main page for the Position object and click New in the Custom Fields & Relationships section.

2.
Select Formula as the data type and click Next to bring up the page shown below.

You define the basic attributes of the formula field on this page.

Figure 56. Defining a formula


3.
Enter Days Since Posting in the Field Label field and select Number as the return type for the formula since this formula returns the number of days since the position was posted. Set the number of Decimal Places to 0 and click Next.



Figure 57. Advanced formula editor


4.
Click the Advanced Formula tab to show the page above.

There are four buttons and pick lists that can help you build formulas: Insert Field Type, Insert Operator, Functions and Insert Selected Function. The Insert Field Type picklist contains all the objects whose fields you can use in this formula. The objects whose name is preceded by a dollar sign ($) are system objects, while the other objects are related to the current object.

Your selection in this first picklist controls the selections shown in the Insert Field picklist. When you select a field in the rightmost picklist, the Formula Editor automatically places the name of that field into the Formula text area.

Insert Operator lets you insert a logical operator into the Formula text area in the same way.

The Functions picklists give you access to all native Force Platform functions. The top picklist allows you to display only a certain type of function in the lower picklist. Once you select a function in the lower picklist, the syntax for the function appears below the picklist, as well as a link to the section of the on-line help, which gives more help for the function. Once you find the right function, the Insert Selected Function does exactly what it says.

5.
Select the TODAY() function in the function list box and click Insert Selected Function.

6.
Click Insert Operation to insert the subtraction operation (-) after the TODAY() function.

7.
Insert the DATEVALUE() function, needed to convert the CreatedDate field from a datetime field to a date field, to perform the calculation.

8.
Highlight the text expression in the DATEVALUE(expression) string and use the Insert Field picklist to insert the CreatedDate field into the formula.

9.
Click Check Syntax to verify that you have not made any syntax errors, add an appropriate description and help text, and click Next.

10.
Accept the default field level security settings and notice that the Read-Only checkbox is automatically selected for a formula field.

11.
Click Next and accept the placement on the Position page by clicking Save.

12.
Click the Positions tab and select an existing position to display the results of your work, as shown below.

Figure 58. Your formula at work


You can easily imagine the usefulness of this formula in future reports. You can even think of a potential problem here. A more useful time span is the number of days since a job was actually opened for applications—a modification you make possible using workflow in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.12.3