Create and Initiate Object Functions
Use these steps to create an object function and use it in Autocomplete Rules.
Create Object Function
-
Enable a sandbox to go to the Configure Business Objects task:
-
Click Navigator > Configuration > Sandboxes.
-
Click Create Sandbox.
-
Enter the Name.
-
Select the Active box for Configure Business Objects.
-
Click Create and Enter.
-
Click Navigator > Tools > Configure Business Objects to configure business objects.
-
-
Scroll down to business object you want to work with (for example, Salary), click the Actions icon and select Edit Business Logic.
-
Click the down arrow to the right and select Object Functions.
-
Click Add in the main editor.
-
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.
-
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.
-
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.
-
Click Save and Close.
Initiate Object Function in Autocomplete Rules
-
Navigate to Autocomplete Rules.
-
Select the same business object, for example, Position.
-
Select Business Object Defaulting as the Rule Type.
-
Define a variable with the same data type as that of the return type of the object function (see step 5 in earlier procedure).
-
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.
-
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;