I'm working on a form in Dynamics 365 Finance & Operations where I need to show an additional field (StakeholderNameDisplay) after selecting a value from a dropdown (lookup) field (RoleCode). The idea is to fetch and display related data (e.g., a stakeholder’s title) without saving this data to the database; it should be for display purposes only.
Scenario
Table: I have a table (TUStakeholderRoles) with fields RoleCode, reportToPosition, and title.
Form: I want to add a display field (StakeholderNameDisplay) that will show the title of the selected stakeholder based on RoleCode.
Behavior: Once I select a RoleCode from the dropdown, the form should display the stakeholder’s title in StakeholderNameDisplay. This title should not be saved back to the table; it’s for display only.
Attempted Solutions
I’ve tried a few approaches but haven’t been able to get it to work as expected. Here’s what I’ve tried so far:
Solution 1: Display Method on Table
I added a display method directly in the table (TUStakeholderRoles) to retrieve the title based on the RoleCode.
public display str StakeholderNameDisplay()
{
TUStakeholderRoles holderRoles;
select firstOnly title from holderRoles
where holderRoles.reportToPosition == this.RoleCode;
return holderRoles ? holderRoles.title : 'NA';
}
This method works on a per-row basis, but when I try to use it on the form, it doesn’t update dynamically after the selection in the dropdown.
Solution 2: Adding the Display Method as a Form Control
I tried to add StakeholderNameDisplay as a control on the form by dragging it from the data source to the form design. However, the display method does not appear in the data source node in the form designer, so I couldn’t directly add it this way.
Solution 3: Using an Unbound Control with Modified Method on Dropdown
Since the display method didn’t show up directly, I added an unbound control (StakeholderNameDisplayControl) on the form. My plan was to update this control with the title dynamically. In the modified method of the dropdown control, I attempted to set the control’s text with the result of the display method:
public void modified()
{
StakeholderNameDisplayControl.text(this.StakeholderNameDisplay());
super();
}
But this approach failed because StakeholderNameDisplayControl was not found in scope within the data source’s methods, even though it’s in the form design.
Solution 4: Refreshing the Data Source to Update the Display Method
In another attempt, I used the modified method on the dropdown to refresh the data source, hoping it would trigger the display method to update dynamically.
public boolean modified()
{
boolean ret;
ret = super();
// Refresh the data source to update the display method field
yourTable_ds.refresh();
return ret;
}
This didn’t produce the desired outcome either, as the display field still did not update dynamically.
Request
I’d appreciate any guidance on how to achieve the following:
Select a value in the RoleCode dropdown.
Automatically display the related title in a form field without saving it to the database.
Ensure the field updates dynamically each time the dropdown value changes.
Any solutions or alternative approaches would be really helpful. Thank you in advance