Object Functions

You use an object function when you can't achieve the specified outcome using the existing capabilities of Autocomplete Rules.

While object functions provide many of the same capabilities that the tool provides, there are also some capabilities that the tool doesn't provide. This table lists cases where you can use object functions.

Rule

Usage

Defaulting Rule

Use an object function to convert the data type of the flexfield segment to the data type expected in the transaction business object. For example, let's say you can't select a default value using the list of values of a field in the business object. And you want to select the value from a predetermined flexfield segment of a setup entity (for example, job, business unit, organization). The conversion logic in the object function differs depending on the return type definition on the flexfield segment-number versus code or name. However, you can use this type of function to show a number as part of an error message, primarily for troubleshooting, since error messages only support variables of type string.

Defaulting or Validation Rule

Use an object function when you have many if then statements and want to reuse the mapping logic among the different rules for the same business object. Since autocomplete rule doesn't have Case or Switch statements, you need to do this inside an object function and return a Boolean to indicate there is a match or return the actual value of the matching combination.

Validation Rule

Use an object function to validate the value received in an ID field for which there is no LOV (for example, People Group on Work Assignment). You can create an Autocomplete rule that does this and review the code generated as an example of how to sample the ID value inside an object function. However, you need to write this function as sampling ID values isn't allowed inside autocomplete rules. Most IDs will have a LOV allowing you to select a specific one.

Any Rule

Use an object function to do any calculation that isn't provided in autocomplete rules. For example, date difference in days.

Note: Don't use object functions to fetch related objects or assign value to business attributes. You need to return the necessary transformed value to assign back to autocomplete rules and execute the assignment inside autocomplete rules only.