HOME COMMUNITY BLOG
Skip to end of metadata
Go to start of metadata

Situation

You have a drop-down on a form and when you select the value, you want another field to fill-up automatically with additional information. This information is not stored, it should be just looked-up, so it can be read-only.

Example

You have the following BusinessPartner entity:

Field NameTypeDescription
IduniqueidentifierPrimary key
NamestringCustomer name
FirstNamestringCustomer first name
PhoneNumberstringCustomer's phone number

Then you have another entity SalesOrder:

Field NameTypeDescription
IduniqueidentifierPrimary key
refBusinessPartnerIduniqueidentifierCustomer
PricecurrencyPrice

You created a Screen Section for the SalesOrder entity where you add these fields:

  • Customer Dropdown
  • Price TextBox
Now you need a TextBox with a customer's phone number.

Solution

The solution is to create a looked-up field in a form's data structure, which will automatically load the values when the form loads, but also when the field value changes, e.g. while the user edits the data.

1. Create a Lookup

Create a lookup for the customer's phone number.

  1. Select BusinessPartner entity.
  2. Right click > Actions > Create Lookup.
  3. As a Display Field select PhoneNumber.
  4. Press OK.

This will create a lookup which loads a phone number by providing a customer's id.

2. Create a Field In a Data Structure

Now you add the looked-up field to the form's data structure.

  1. Go to Data > Entities and select the SalesOrder entity.
  2. Right click > New > Lookup Field.
AttributeValueDescription
FieldrefBusinessPartnerIdThe field by which we will load the phone number.
LookupBusinessPartner_PhoneNumberBy this lookup the value will be looked-up, so the result will be the phone number instead of the customer's id.
NameBusinessPartner_PhoneNumberLet's rename the field so it indicates the content (what we take and from where).

Now we have the data source configured so it will contain a phone number. It will also automatically reload when the lookup source parameter (refBusinessPartnerId) changes so the UI does not have to care about this.

3. Add the Field To the Form

In this last step we will place the Phone Number field on the form.  

  1. Open the Screen Section based on the SalesOrder entity.
  2. In the SalesOrder tab in the Toolbox select the BusinessPartner_PhoneNumber field.
  3. Change to the Widgets tab in the Toolbox, select AsTextBox/AsDateBox and drag it onto the panel.
  4. In the Properties find the (DataBindings) and expand it. The DateValue should show OrigamDataSet - SalesOrder.BusinessPartner_PhoneNumber (the SalesOrder being your current entity name and the BusinessPartner_PhoneNumber your looked-up field).
  5. Set ReadOnly to True as this field is not editable anyway.

That's it. Now you have manually bound the text field with the looked-up field that will be provided when you execute the form.