如何获取 FormReferenceGroupControl 的值

How to get value of FormReferenceGroupControl

在D365窗体开发中,我喜欢获取输入到窗体控件中的值,窗体控件是一个带有Party引用字段的窗体引用组控件。

如何获取输入到控件的值?

尝试过:

ReferenceGroup.controlNum(i).valueStr();

FieldBinding 与 filterValue

两者都不起作用。

它应该像调用 FormReferenceGroupControl 对象上的 value() 方法一样简单,以获取底层的 Reference 值 (int64),这是底层数据源的 RecId。例如:

FormReferenceGroupControl referenceGroupControl;

referenceGroupControl = element.control(element.controlId(formControlStr(ReferenceGroupTestingForm, ReviewHeaderInfo_CustomsRepRefGroup))) as FormReferenceGroupControl;

referenceGroupControl.value(); //returns the RecId of the DirPerson table displayed.

要获取替换为用户的 显示值,而不是存储在数据库中的基础 RecId 值,请执行以下操作:

FormReferenceGroupControl referenceGroupControl;

referenceGroupControl = element.control(element.controlId(formControlStr(ReferenceGroupTestingForm, ReviewHeaderInfo_CustomsRepRefGroup))) as FormReferenceGroupControl;

//this gets the string control that is substituted in for the reference value/recid and displayed to the user. This is the second underlined control in the picture below. This control is determined by the ReferenceGroupControl property "Replacement Field Group" 
//Could be a different type of control than a String control depending on your scenario
FormStringControl subStringControl = referenceGroupControl.controlNum(1) as FormStringControl;

subStringControl.text(); //for string controls, text will contain the display value

最后要注意的一件事是,我相信可以通过操作数据源对象而不是表单控件对象来获取值。我过去在搜索 google 搜索结果时见过这样的解决方案。如果我再遇到他们我会更新答案