Creating User-Defined Attributes
This topic describes the procedure for creating a user-defined or custom attribute for a business object. You can add a user-defined attribute to any of the available business objects.
Before you begin
About this task
Procedure
To create a user-defined attribute for the Request business object, complete the following steps:
- Log in to Emptoris® Program Management as a user with the System Administrator role.
- From the Administration tab, expand Roles > Default > Business Objects > Request.
- Click Attributes, and in the Attributes screen for the Request business object, click Create Attribute.
- In the Create Attribute window for the Request business object, enter the
necessary details. The fields in the Create Attribute window for the Request
business object are described in the following table:
Table 1. Create Attribute for Request Business Object Field Description Name Enter the name of the user-defined attribute. The name must not contain blank spaces, special characters, and numbers. This field is mandatory.
Type Select the type of the user-defined attribute from the list. The default value is String. This field is mandatory.
The most commonly used attribute types and examples of their corresponding attributes are as follows:
- String - The following example describes the use of this attribute type:
- You can define the attribute to accept a free text response from the user. The responses can contain a maximum of 4000 characters. You can also specify a character limit.
- Integer - The following example describes the use of this attribute type:
- You can define the attribute to accept only a whole number. For example, the user can enter the number of employees.
- Float - The following example describes the use of this attribute type:
- You can define the attribute to accept only a real number of 32-bit values. For example, the price of a stock.
- Double - The following example describes the use of this attribute type:
- You can define the attribute to accept only a real number of 64-bit values. For example, the output of a mathematical function that calculates an iterative operation.
- Date - The following example describes the use of this attribute type:
- You can define the attribute to accept the date value in the specified format.
- Boolean - The following examples describe the use of this attribute type:
- You can define the attribute to accept a yes or no response from the user.
- You can define the attribute to accept a true or false response from the user.
- Currency - The following example describes the use of this attribute type:
- You can define the attribute to accept only valid currency values. For example, the user can enter an amount in dollars.
Form Label Enter the label of the form. The form label indicates the name of the control in the form in which this user-defined attribute is used. This field is mandatory.
Control Type We recommend selecting the Default value from the list. Depending on the values that are entered in the other fields, the control type is automatically changed when this user-defined attribute is saved. You can change the control type in the form in which this user-defined attribute is used.
Column Label Enter the label of the column. The column label indicates the name of the column that is displayed when this user-defined attribute is selected for viewing in a table view. This column name is also displayed in the Reports that contain this user-defined attribute. This field is mandatory.
Default Enter the default value for this user-defined attribute. This default value is displayed in the form in which this user-defined attribute is used. Currency Attribute Enter the name of the currency attribute. If the attribute that you are creating is a currency type attribute, and you want to have the currency of this field driven by a currency field on the associated form, you must indicate the name of the currency attribute here.
For certain business objects, such as Project, the “currency” attribute exists. If you create a user-defined attribute for a business object that does not contain the currency attribute, you must create it with the Type as Currency, the Mapping Type as Many to one, and the mapping to reference the primary key of the CURRENCY table.
For example, for the Request business object, enter the following expression in the Mapping field: REQUEST.CURRENCY_CODE = CURRENCY.CURRENCY_CODE. Then, when you create or edit a request, if you select, for example, USD in the Currency list, USD is displayed next to the custom user-defined currency field.
Currency Date Attribute Enter the value of the currency date attribute. The Currency Date Attribute indicates the name of the Date type attribute from the current business object or a related business object. The value of the currency date attribute is used to determine the currency exchange rate. This currency exchange rate is used when you convert the amount from one currency to another currency in features such as Reporting.
For example, the Start date attribute is specified as the currency date attribute for projects. Therefore, you can enter the name of this attribute, startDate, in the Currency Date Attribute for the currency amount fields such as Savings in Project.
The currency attributes that are tied to a date designation field utilize the exchange rate that contains the appropriate applicable exchange date. Where a currency attribute is not tied to a date designation field, the active exchange rate is utilized.
Size Enter the value for the size. The size indicates the maximum bytes of characters that can be entered in a field that requires user input in this user-defined attribute. The value must not exceed the size of the associated database column. The default value is 255.
Note: If you allow multi-byte characters in the user input in this user-defined attribute, ensure that the value of the size is appropriate. For example, a field size of 100 is suitable for 100 single-byte characters, but can accept only 25 multi-byte characters.Format Select the required format from the list. Ensure that you select the appropriate format from the list. For example, if the selected Type is String, the Currency format is unsuitable. For values with decimal places, use the Number With Separator format.
Precision Enter the number of digits in the fractional part of the number after the decimal separator. This value is valid only if the selected Type is Double, Float, or Integer. The default value is zero. The precision depends on the format that you specify. The following list describes the influence of the various formats on precision.
- Number with Separator: The fractional part of the number is rounded to the specified number of digits.
- No Format: If the format is not specified, the precision is not calculated.
- Currency: The fractional part of the number is rounded to two digits, irrespective of the specified precision.
- Number: The fractional part of the number is rounded to three digits, irrespective of the specified precision.
Required Select the check box if you want to include this user-defined attribute as a mandatory field in a form. View Select the check box if you want this user-defined attribute to be viewable in the form in which, this user-defined attribute is used. You can clear the check box if you want this user-defined attribute to remain hidden and not display in any form. This action is useful when you want to use this user-defined attribute only as a storage location for establishing a back-end calculation.
Edit Select the check box if you want to allow the user to edit this user-defined attribute. Search Select the check box if you want this user-defined attribute to be available for simple and advanced search. Sort Select the check box if you want this user-defined attribute to be sortable. Edit All Select the check box if you want this user-defined attribute to be editable for several objects in one operation by the user. Note: This option is applicable only if the Edit All permission is enabled for the user.For example, if you want to edit the value of the user-defined attribute in multiple requests, navigate to Requests > All Requests > Options > Edit All.
Unique Select the check box if you want this user-defined attribute to perform unique behavior. It indicates that the data stored in this user-defined attribute is treated as unique. For example, you can configure this user-defined attribute in a request form such that the request you want to link to a project must not be linked to any other project.
Mapping Type Select the required mapping type from the list. Mapping type indicates how this user-defined attribute is mapped to the database table column. This field is mandatory. The following mapping types are available:
- Derived: The attribute is derived from a calculation of one or more fields.
- Direct: The attribute is stored directly in the database table column.
- Many to one: You can use this mapping type to point this attribute to a primary key of another
business object. By using this mapping type, you can link many attributes of this business object to
one attribute of the other business object.
This mapping type is used if a business object is selected in the Type attribute, for example, User.
- One to many: Implementation-specific usage. For example, one project can link to many requests, or many suppliers can link to one task.
- Unmapped: The unmapped attribute is not stored. This selection requires custom input from SDG on the getter and setter implementations of the attribute.
For information on how to map an attribute to a field in the database table, see Defining Column in Database for a User-Defined Attribute.
Mapping Indicates the details of the mapping type. This field is used with the One to Many or the Many to One mapping types. You can designate the primary key of the object you are linking to. For example, the mapping syntax for the Many to One mapping type is foreign key = primary key, that is, the attribute references primary key of the table for the object that is selected in Type list.
For information on how to map an attribute to a field in the database table, see Defining Column in Database for a User-Defined Attribute.
Upper Case Select the check box if you want the value that is entered in the user-defined attribute to be displayed in capital letters. This field is available only if the selected Type is String. Minimum Range Enter the minimum value that is allowed in the range of values. This field is available only if the selected Type is Double or Integer. Maximum Range Enter the maximum value that is allowed in the range of values. This field is available only if the selected Type is Double or Integer. Getter Implementation Click the icon to enter or edit the Beanshell script. Using bean shell script, you can allow an attribute value or values to be returned from other attributes. This attribute is used with the setter. Setter Implementation Click the icon to enter or edit the Beanshell script. Using bean shell script, you can allow an attribute value to be set. This value can be considered the result of a calculation if it returns “getter” values. Description Enter a short description of this user-defined attribute. The text that you enter in this field is displayed as the help text for the field in the form in which, this user-defined attribute is used. Validation Values: Query Select the option if you want to validate this user-defined attribute against specific values that are generated based on a query criteria. The Query option can be specified only if you select Type as Business Object. For an example of how to create a query for the Request business object, see the Example section in this topic.
Validation Values: Reference Category Select the option if you want to validate this user-defined attribute against a reference category that you select from the list. Validation Values: SQL Select the option if you want to validate this user-defined attribute against an SQL query. Validation Values: Values Select the option if you want to validate this user-defined attribute against values that you manually select from the Edit Values window. - String - The following example describes the use of this attribute type:
- Click OK.
- In the Mapping/Type Changed window,
click Yes. Note: The other users who are currently logged in to the system are forced to log off.
- In the Metadata Reloaded window, click OK.
It is recommended that reload metadata action is triggered only when no users are in the system and when there are no background jobs being executed, such as batch upload jobs.
Example
This example describes how to create a Validation Values: Query for the Request business object.
- For the Request business object, create an attribute with type as ‘User’, Mapping Type as ‘Many to one’, and Control Type as ‘Dropdown’.
- Save the changes.
- Navigate to Business Objects > User > Queries.
- Create a new Query with name as ‘Test’, clear the ‘Display as a Query Folder’ check box, and specify an expression.
- Save the query.
- In the Request attribute, expand Query, select ‘Test’, and save the attribute.
- Add a new field to the request form and map it to the new attribute.
When you create or edit the Request, this control is rendered as a list and it contains only those values that fulfill the query criteria.
- Defining Column in Database for a User-Defined Attribute
During the creation of a user-defined or custom attribute for a business object, you can map the user-defined attribute to the database table column.