Formulas - Transactions Editor
The admins use the formulas to calculate values of a field based on other fields, functions, literals, or expressions.
Formulas are associated to the current SFM transaction. The formula tab is enabled for all types of SFM Transactions (except for the SFM transaction To create mobile view).
Launching Formula Editor
Navigate to Home > ServiceMax Setup > Service Flow Manager > Transactions > Transactions List View > Properties > Formulas.
The following screen displays the Landing page of the Formulas:
Adding Formula from Library
This enables the user to associate a formula from the existing list of formulas.
1. Click on theAdd Formula from the Library button. A pop-up screen is displayed with a list of formulas. The list of formulas with the matching alias and display name configured in the header and child cards are displayed.
2. Choose from a list of formulas on the pop-up page.
3. Click the Apply button. The pop-up screen displays the list of formulas associated as per the sequence of selection done.
The following screen displays the list of Formulas:
The following screen displays the list of formulas selected according to the sequence of selection:
Rearranging Associated Formulas
This action allows to control order of formula execution at runtime. Place your cursor on the name of the associated formula to rearrange the sequence or delete it. You either move the formula up or down based on its position.
To remove the associated formula, use the ‘x’ icon to erase the formula.
The following screen displays the options to rearrange or remove a formula:
Creating a New Formula
Click on the New Formula button to launch the Formula Editor in a new tab. The Formula Editor allows you to create a formula.
The following screen displays the New Formula button:
Configuring a Formula
The Formula Editor allows you to configure a formula for a specific field in an object. The formulas can comprise target objects configured for the process, and are allowed to use custom functions like logical and mathematical operators.
The following screen displays the Landing page for the Formula Editor:
The following table lists the fields of the Formula Editor.
Field Name
Description
Title
This displays the title of the formula. The title is editable. In the edit mode, the title is pre-populated.
Description
This displays the description of the formula used. The description is editable.
Target Object
This displays the name of the Target Object based on which the formula is configured.
Target Field
This displays the name of the Target Field based on which the formula is configured.
Cancel
This allows you to disassociate the current formula.
Save
This allows you to save a formula.
Delete
This allows you to delete a formula in the edit mode.
The following screen displays the Landing page of the Formula Editor in Edit mode:
Creating a Formula from the Object Field
To create a formula perform the following actions:
1. Configure a formula by clicking on an available object field.
2. Click the object field and it is added to the Formula Text area.
In the following example, the user has created a formula by clicking on the object fieldBillable Line Price . On tapping on the name of the field, it is appended in the adjacent text area.
The following screen displays the adjacent text area:
* 
The fields that are part of the formula are stored in the Related Info field of the configuration record. A field may or may not be added to the page layout for formulas to be executed on Web Delivery.
Searching Formulas
The Search Panel field allows you to look for a keyword in the Field or Functions section.
For example, if the user searches for the keyword asPrice , the results are displayed.
The following screen displays the Search panel for the Field section:
Formula Functions
This section lists the supported Formula functions based on their types along with descriptions and examples.
Conditional Functions
The following table lists the Conditional functions in Formula Editor.
Function Signature
Description
Example
IF (logical_test, value_if_true, value_if_false)
Checks whether a condition is true and returns one value if TRUE and another value if FALSE.
Target Field: Work Order > Billing Type
Requirement: Leave Billing Type unchanged if Customer Down is checked; else, set it to Paid.
Formula: $F.IF($F.EQUAL($D.Work_Order.SVMXC__Customer_Down__c,'true'), $D.Work_Order.SVMXC__Billing_Type__c, 'Paid')
AND (logical1,logical2,..)
Checks whether all arguments are true and returns TRUE if all arguments are true
Target Field: Work Order > Billing Type
Requirement: Leave Billing Type unchanged if Customer Down is checked AND Order Status is Open AND Order Type is Field Service; else, set it to Paid.
Formula: $F.IF($F.AND($F.EQUAL($D.Work_Order.SVMXC__Customer_Down__c, 'true'), $F.EQUAL($D.Work_Order.SVMXC__Order_Status__c, 'Open'), $F.EQUAL($D.Work_Order.SVMXC__Order_Type__c, 'Field Service')), $D.Work_Order.SVMXC__Billing_Type__c, 'Paid')
OR (logical1,logical2,..)
Checks whether any of the arguments are true and returns TRUE or FALSE. Returns FALSE only if all arguments are false
Target Field: Work Order > Billing Type
Requirement: Leave Billing Type unchanged if Customer Down is checked OR Priority is High OR Is PM Work Order is checked; else, set it to Paid.
Formula: $F.IF($F.OR($F.EQUAL($D.Work_Order.SVMXC__Customer_Down__c, 'true'), $F.EQUAL($D.Work_Order.SVMXC__Priority__c, 'High'), $F.EQUAL($D.Work_Order.SVMXC__Is_PM_Work_Order__c, 'true')), $D.Work_Order.SVMXC__Billing_Type__c, 'Paid')
NOT (logical)
Changes FALSE to TRUE or TRUE to FALSE
Target Field: Work Order > Order Type
Requirement: Set Order Type to Depot Repair if City is not Los Angeles and Is PM Work Order is not checked; else, leave Order Type unchanged.
Formula: $F.IF($F.NOT($F.OR($F.EQUAL($D.Work_Order.SVMXC__City__c,'Los Angeles'), $F.EQUAL($D.Work_Order.SVMXC__Is_PM_Work_Order__c, 'true'))), 'Depot Repair', $D.Work_Order.SVMXC__Order_Type__c)
NULL
Clears the field value
Configure this literal on any target field to clear its value. Formula: $F.SETNULL()
Date Functions
The following table lists the Date functions in Formula Editor.
Function Signature
Description
Example
TODAY()
Returns the current date in logged user's time zone when used with a date field.
Returns 12 AM on current date (logged in user's time zone) when used with a datetime field. When this value is assigned to a text type field, the format of the returned value is yyyy-MM-dd.
Target Field: Work Order > Scheduled Date
Requirement: Set Scheduled Date to today.
Formula: $F.TODAY()
NOW()
Returns the datetime in logged in user's time zone, representing the current moment. When the returned value is assigned to a text type field, the format of the returned value is yyyy-MM-dd HH:mm:ss, in logged in user's time zone.
Target Field: Work Order > Actual Onsite Response Requirement: Set Actual Onsite Response to now. Formula: $F.NOW()
DATE(year,month,day)
Creates a date from year, month and day, where all are numeric values / fields, with year being specified as a 4-digit number. When the returned value is assigned to a text type field, the format of the returned value is yyyy-MM-dd.
Target Field: Work Order > Next Scheduled Date (custom field)
Requirement: Set Next Scheduled Date to 1st day of the created month in next year.
Formula: $F.DATE($F.YEAR($D.Work_Order.CreatedDate)+1, $F.MONTH($D.Work_Order.CreatedDate), 1)
DATEVALUE(expression)
Creates a date in the logged in user's time zone, from its datetime or text representation.
When the argument is a string / text field, the expected format is yyyy-MM-dd HH:mm:ss or yyyy-MM-dd in the logged in user's time zone, for date and datetime values, respectively.
Target Field: Work Detail (Labor) > Start Date (custom field)
Requirement: Set Start Date to the date part of Start Date and Time field.
Formula: $F.DATEVALUE($D.Labor.SVMXC__Start_Date_and_Time__c)
DATETIMEVALUE(expression)
Creates a datetime in the logged in user's time zone, from its date or text representation. If the argument is a date, 12 AM in the logged in user's time zone is considered as the time to create the datetime value.
When the argument is a string / text field, the expected format is yyyy-MM-dd HH:mm:ss or yyyy-MM-dd in the logged in user's time zone, for date and datetime values, respectively.
Target Field: Work Order > Next Scheduled Date Time (custom field)
Requirement: Set Next Scheduled Date Time to 12 AM on the 1st day of the created month in next year.
Formula: $F.DATETIMEVALUE($F.DATE($F.YEAR($D.Work_Order.CreatedDate)+1, $F.MONTH($D.Work_Order.CreatedDate), 1))
DATEDIFF(date1,date2,option)
Returns the difference between two date or datetime fields in days/weeks/months/years. The value returned is negative if value2 is greater than value1.
unit_of_difference must be INDAYS, INWEEKS, INMONTHS, or INYEARS.
The returned number can be set as the value of a text type field also.
Target Field: Work Order > Initial To Completion Days (custom field)
Requirement: Difference in days from Actual Initial Response to Completed Date Time
Formula: $F.DATEDIFF($D.Work_Order.SVMXC__Completed_Date_Time__c, $D.Work_Order.SVMXC__Actual_Initial_Response__c, 'INDAYS')
DAY(date or datetime)
Returns the day of the month, a number between 1 and 31, for the date or datetime value argument passed. The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Day (custom field)
Requirement: Set Activity Day to the day of the month of Start Date and Time field.
Formula: $F.DAY($D.Labor.SVMXC__Start_Date_and_Time__c)
MONTH(date or datetime)
Returns the month, a number between 1 (January) and 12 (December), for the date or datetime value argument passed. The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Month (custom field)
Requirement: Set Activity Month to the day of the month of Start Date and Time field.
Formula: $F.MONTH($D.Labor.SVMXC__Start_Date_and_Time__c)$F.Add($F.DAY($D.Labor.SVMXC__Start_Date_and_ Time__c),1)
YEAR(date or datetime)
Returns the year of a date, a number between 1900 and 9999, for the date or datetime value argument passed. The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Year (custom field)
Requirement: Set Activity Year to the day of the month of Start Date and Time field.
Formula: $F.YEAR($D.Labor.SVMXC__Start_Date_and_Time__c)
Logical Functions
The following table lists the Logical functions in Formula Editor.
Function Signature
Description
Example
EQUAL(value1,value2)
Compares the two arguments and returns TRUE if they are the same. Returns FALSE if they are different. The field type of the arguments must be the same.
Target Field: Work Order > Order Type Requirement: If City is San Jose, set Order Type to Depot Repair; else, leave Order Type unchanged. Formula: $F.IF($F.EQUAL($D.Work_Order.SVMXC__City__c,'San Jose'), 'Depot Repair', $D.Work_Order.SVMXC__Order_Type__c)
NOTEQUAL(value1, value2)
Returns the datetime in logged in user's time zone, representing the current moment. When the returned value is assigned to a text type field, the format of the returned value is yyyy-MM-dd HH:mm:ss, in logged in user's time zone.
Target Field: Work Order > Order Type Requirement: If City is not Los Angeles, set Order Type to Depot Repair; else, leave Order Type unchanged. Formula: $F.IF($F.NOTEQUAL($D.Work_Order.SVMXC__City__c,'Los Angeles'), 'Depot Repair', $D.Work_Order.SVMXC__Order_Type__c)
LESSTHAN(value1, value2)
Compares the two arguments and returns TRUE if value1 is less than value2. Returns FALSE if value1 is equal to or greater than value2. The field type of the arguments must be the same.
Target Field: Work Detail (Labor) > Discounted Line Price (custom field) Requirement: If Discounted Line Price is less than 10.45, set it to 10.45; else, leave Discounted Line Price unchanged. Formula: $F.IF($F.LESSTHAN($D.Labor.Discounted_Line_Price__c, 10.45), 10.45, $D.Labor.Discounted_Line_Price__c)
LESSTHANEQUAL(value1, value2)
Compares the two arguments and returns TRUE if value1 is less than or equal to value2. Returns FALSE if value1 is greater than value2. The field type of the arguments must be the same.
Target Field: Work Detail (Labor) > Discounted Line Price (custom field) Requirement: If Discounted Line Price is less than or equal to 10.4, set it to 10.5; else, leave Discounted Line Price unchanged. Formula: $F.IF($F.LESSTHANEQUAL($D.Labor.Discounted_Line_Price__c, 10.4), 10.5, $D.Labor.Discounted_Line_Price__c)
GREATERTHAN(value1, value2)
Compares the two arguments and returns TRUE if value1 is greater than value2. Returns FALSE if value1 is equal to or less than value2. The field type of the arguments must be the same.
Target Field: Work Detail (Labor) > Discounted Line Price (custom field) Requirement: If Discounted Line Price is greater than 100, set it to 100; else, leave Discounted Line Price unchanged. Formula: $F.IF($F.GREATERTHAN($D.Labor.Discounted_Line_Price__c, 100), 100, $D.Labor.Discounted_Line_Price__c)
GREATERTHANEQUAL(value1, value2)
Compares the two arguments and returns TRUE if value1 is greater than or equal to value2. Returns FALSE if value1 is less than value2. The field type of the arguments must be the same.
Target Field: Work Detail (Labor) > Discounted Line Price (custom field) Requirement: If Discounted Line Price is greater than or equal to 100, set it to 99; else, leave Discounted Line Price unchanged. Formula: $F.IF($F.GREATERTHANEQUAL($D.Labor.Discounted_Line_Price__c, 100), 99, $D.Labor.Discounted_Line_Price__c)
Math Functions
The following table lists the Math functions in Formula Editor.
Function Signature
Description
Example
ADD(value1, value2)
Adds two numeric values. The values are numbers or field identifiers of numeric fields (number, currency, percent).
Target Field: Work Order > Total Parts Labor Price (custom field) Requirement: Set Total Parts Labor Price to the sum of Total Parts Price and Total Labor Price (both custom Work Order fields). Formula: $F.ADD($D.Work_Order.Total_Parts_Price__c, $D.Work_Order.Total_Labor_Price__c)
SUBTRACT(value1, value2)
Subtracts value2 from value1. The values are numbers or field identifiers of numeric fields (number, currency, percent).
Target Field: Work Order > Total Parts Labor Price (custom field) Requirement: Subtract 5 from Total Parts Labor Price. Formula: $F.SUBTRACT($D.Work_Order.Total_Parts_Labor_Price__c, 5)
MULTIPLY(value1, value2)
Multiplies value1 by value2. The values are numbers or field identifiers of numeric fields (number, currency, percent).
Target Field: Work Detail (Labor) > Calculated Line Price (custom field) Requirement: Set Calculated Line Price to Line Price Per Unit * Line Qty Formula: $F.MULTIPLY($D.Labor.SVMXC__Actual_Quantity2__c, $D. Labor.SVMXC__Actual_Price2__c)
DIVIDE((value1, value2))
Divides the dividend by divisor (dividend / divisor). The values are numbers or field identifiers of numeric fields (number, currency, percent).
Target Field: Work Detail (Labor) > Calculated Line Price (custom field) Requirement: Set Calculated Line Price to half of its value. Formula: $F.DIVIDE($D.Labor.Calculated_Line_Price__c, 2)
Rollup Functions
The following table lists the Rollup functions in Formula Editor.
Function Signature
Description
Example
SUMOF(lines_section_identifier, '<field_API_name>')
Returns the sum of all the numbers in the given list of numbers. The numbers are identified by the API name of the field and the list is identified by the lines section identifier. Numbers include currency and percent field types also.
Target Field: Work Order > Total Parts Price (custom field) Requirement: Set Total Parts Price to the sum of Discounted Line Price (custom field) of all the Parts lines section records. Formula: $F.SUMOF($D.Parts, ‘Discounted_Line_Price__c’)
AVGOF(lines_section_identifier, '<field_API_name>')
Returns the average of all the numbers in the given list of numbers. The numbers are identified by the API name of the field and the list is identified by the lines section identifier. Numbers include currency and percent field types also.
Target Field: Work Order > Average Parts Price (custom field) Requirement: Set Average Parts Price to the average of Discounted Line Price (custom field) of all the Parts lines section records. Formula: $F.AVGOF($D.Parts, ‘Discounted_Line_Price__c’)
MINOF(lines_section_identifier, '<field_API_name>')
Returns the minimum of all the numbers in the given list of numbers. The numbers are identified by the API name of the field and the list is identified by the lines section identifier. Numbers include currency and percent field types also.
Target Field: Work Order > Minimum Parts Price (custom field) Requirement: Set Minimum Parts Price to the minimum of Discounted Line Price (custom field) of all the Parts lines section records. Formula: $F.MINOF($D.Parts, ‘Discounted_Line_Price__c’)
MAXOF(lines_section_identifier, '<field_API_name>')
Returns the maximum of all the numbers in the given list of numbers. The numbers are identified by the API name of the field and the list is identified by the lines section identifier. Numbers include currency and percent field types also.
Target Field: Work Order > Maximum Parts Price (custom field) Requirement: Set Maximum Parts Price to the maximum of Discounted Line Price (custom field) of all the Parts lines section records. Formula: $F.MAXOF($D.Parts, ‘Discounted_Line_Price__c’)
* 
For Math and Rollup functions, any field with blank values is considered as zero.
Field Types and Formulas in Formula Editor
Formulas are supported for multiple types of editable fields as follows:
Check box
Date, Datetime
Currency, Number , Percent
Email, Long Text Area, Phone, Text, Text Area, URL
Picklist, Multi-select Picklist
Formulas are not supported for the following field types:
Encrypted Text, Rich Text Area
Geolocation
Lookup Relationship, Master-Detail Relationship, External Lookup Relationship
The following table lists all the logical functions supported by different field types:
Function Signature
Description
Check box
EQUAL, NOTEQUAL, LESSTHAN, LESSTHANEQUAL, GREATERTHAN, GREATHANEQUAL
Currency
EQUAL, NOTEQUAL
Date
EQUAL, NOTEQUAL
Date/Time
EQUAL, NOTEQUAL
Email
EQUAL, NOTEQUAL
Number
EQUAL, NOTEQUAL, LESSTHAN, LESSTHANEQUAL, GREATERTHAN, GREATHANEQUAL
Percent
EQUAL, NOTEQUAL
Phone
EQUAL, NOTEQUAL
Picklist
EQUAL, NOTEQUAL
Picklist (Multi-Select)
EQUAL, NOTEQUAL
Text
EQUAL, NOTEQUAL, LESSTHAN, LESSTHANEQUAL, GREATERTHAN, GREATHANEQUAL
Text Area
EQUAL, NOTEQUAL, LESSTHAN, LESSTHANEQUAL, GREATERTHAN, GREATHANEQUAL
Long Text Area
EQUAL, NOTEQUAL, LESSTHAN, LESSTHANEQUAL, GREATERTHAN, GREATHANEQUAL
URL
EQUAL, NOTEQUAL
Formula Execution
In the Classic Designer, the options of On Load and On Save are non-existent. The default formula execution mode was Always (both On Save and On Load). In the SFM Transactions Designer, there is an option for the Admin to configure between On Load, On Save, and Always.
On Load: This option executes the formula before the page loads.
On Save: This option executes the formula after the user performs Save and submits the page.
Always: This option is the default mode for any new or existing formulas. The Always option executes both On Load and On Save mode of the page.
Refresh List
The Refresh List button displays the latest list of formulas available for the user. It adds the created formulas and removes the deleted formulas from the list and shows the updated list of formulas to the user.
The following screen displays the Refresh List button highlighted:
Was this helpful?