Languages: Java, .NET, .NET Mobile
Objects: Transactions
Controls: Edits
Interfaces: Windows, Web
The purpose of this feature is to subtitute what the user needs to type in an attribute with a more user friendly value. For example in an Invoice form, users must type the Customer Code, but remembering all the Codes can be a very hard task. Off course a Prompt form is automatically provided by GeneXus , but why not let the user type the Customer Name and let the program automatically look for the corresponding Code?
To do that developers just need to set the property InputType in CustomerCode as 'Description' and CustomerName as the Description Attribute. This can be done over attributes or Edit Controls. If it is applied to an attribute, this will be the default every time the attribute appears on a transaction.
When InputType = Descriptions is set, the "Description" attribute must be in the transaction structure. Otherwise, the following specification error will appear:
On the other hand the description attribute must be a char or varchar. Otherwise spc0112("Item value %1 for control %2 must be Character or VarChar") specification error will be shown.
This feature is usually used in conjunction with the Suggest property .
Let's consider the Countries and Customers transactions, where all Customers belong to a Country.
The traditional way of entering data requires that once the Customer identifier and name have been entered, the Country identifier must be entered by inferring CountryName.
On the other hand, setting InputType = Descriptions will allow you to enter CountryName instead of CountryID.
In order to make this work, each description must match only one Value (in this case, each CountryName must match only one CountryID). That is to say, the description must be a candidate key, so as to create a unique index for each description. If this index is not created, the following warning will appear:
When not defining a unique index and having duplicated values for the description field, an error will be shown every time that one of those duplicated values is chosen. The error message is "%1 is ambiguous" being %1 the description attribute title or the referenced table description if 9.0 U1 or previous is being used. Example:
"Customer Name is ambiguous" being "Customer Name" the description attribute title.
Finally, the result of applying "InputType = Description" will be the following:
Take into account that when setting CountryID as InputType = Descriptions in the attribute itself (design), the CountryName control will be automatically taken out of the default form for those transactions which has a foreign key to County table. However, the form created for the Country transaction will remain normal, that is to say, it will not have InputType = Descriptions for CountryID and will have CountryName in the form as expected.
Conditions allow you to limit the set of possible values to be entered. To do so, you only need to configure the Condition property as follows:
In the example above, we are limiting the control to only accept Countries that begin with the letter "U." When trying to enter a country which name doesn´t begin with "U" (doesn´t match the condition), a "No matching <table>" message will be shown.
When inserting a condition, it is possible to use attributes of the extended table of the "Value" (or Description) attribute. E.g.: In the example shown above, if Country would have a foreign key to e.g. "Continent" it would be possible to use the "ContinentName" attribute in the conditions as it can be inferred from CountryId.
The Instantiated Attributes property is another way of limiting the set of possible values to be entered. This property is used to filter the set of attributes depending on other attributes that can't be inferred directly. Let's consider the following example:
In a multi-company system we have a table with all products, and another table with all the products that the company can sell. Therefore, if we have a products combo box, we can only see the products of the instantiated company.
Consider the following transactions:
And the following relationship:
If we set ProductID as InputType = Descriptions, most likely we will want to enter only those products that belong to the selected company (that is to say, the products instantiated by this company). To define that the allowed products are only those that the company can sell, we must indicate it in the new "Instantiated Attributes" property.
Comments & Collaboration
Guscarr The documentation says: "When not defining a unique index and having duplicated values for the description field, an error will be shown every time that one of those duplicated values is chosen."
English: the error message is "%1 is ambiguous" being %1 the description attribute title or the referenced table description if 9.0 U1 or previous is being used.
Example: "Customer Name is ambiguous" being "Customer Name" the description attribute title.
Español: el mensaje de error es "%1 es ambiguo" siendo %1 el título del "description attribute" or la descripción de la tabla referenciada si se está usando 9.0 U1 o anteriores.
Por ejemplo: "Nombre de Cliente es ambiguo" siendo "Nombre de Cliente" el título del "description attribute".
Interesting links
Input Type and Suggest working together
Suggest property
Official 'GeneXus and Ajax' site
Sample to see ajax features running online
More information about AJAX