Create and Initiate Object Functions

Use these steps to create an object function and use it in Autocomplete Rules.

Create Object Function

  1. Enable a sandbox to go to the Configure Business Objects task:

    1. Click Navigator > Configuration > Sandboxes.

    2. Click Create Sandbox.

    3. Enter the Name.

    4. Select the Active box for Configure Business Objects.

    5. Click Create and Enter.

    6. Click Navigator > Tools > Configure Business Objects to configure business objects.

  2. Scroll down to business object you want to work with (for example, Salary), click the Actions icon and select Edit Business Logic.

  3. Click the down arrow to the right and select Object Functions.

  4. Click Add in the main editor.

  5. Enter a Name, and select a return type of the function. The return type determines when the object function is displayed in Autocomplete Rules. When you define a variable of a certain type, only object functions returning the same data type value are shown.

  6. Expand the parameters section and click Add from the Actions menu. Enter a name and select the parameter type. The parameter type determines the type and number of variables you can pass from Autocomplete Rules to the object function as an input.

  7. Enter the code in the main script editor section, and click Validate. You can view any code generated by Autocomplete Rules with similar logic as a reference for how the script will be built.

  8. Click Save and Close.

Initiate Object Function in Autocomplete Rules

  1. Navigate to Autocomplete Rules.

  2. Select the same business object, for example, Position.

  3. Select Business Object Defaulting as the Rule Type.

  4. Define a variable with the same data type as that of the return type of the object function (see step 5 in earlier procedure).

  5. Change the operand type of the argument on the right hand side by clicking on xyz icon, to Function. By default, the first available standard function is shown. Click the name of the function on which you're now. You can now see 3 options as opposed to 2 when there are no object functions. Select the third object function and pick the function you just created.

  6. You can now provide the parameters you defined in the function using the same data type as in the object function and in the same sequence you defined them in the object function. These can be literal values, variables, or fields of appropriate data type.

Example of Groovy Code

This is an example of groovy code.

Case/Switch
switch (vWorkSchedule) {
case 'MY_SEA_PT_OPT_0_20_ALL': 
return 'Option 1 selected'
break;

case 'MY_FT_OPT_28_40_ALL':
return 'Option 2 selected'
break;

default:
return 'Cannot Identify Input'
break;
}
return true;