Axapta 如何获取FormReferenceGroupControl的值

Axapta 如何获取FormReferenceGroupControl的值,axapta,x++,dynamics-365-operations,Axapta,X++,Dynamics 365 Operations,在D365表单开发中,我喜欢获取表单控件中输入的值,表单控件是一个带有Party引用字段的表单引用组控件 如何获取输入到控件的值 试用: ReferenceGroup.controlNum(i.valueStr() 具有filterValue的字段绑定 两者都不起作用 它应该像调用FormReferenceGroupControl对象上的value()方法一样简单,以获取底层的引用值(int64),它是底层数据源的RecId。例如: FormReferenceGroupControl refer

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

如何获取输入到控件的值

试用:

ReferenceGroup.controlNum(i.valueStr()

具有filterValue的字段绑定

两者都不起作用


它应该像调用FormReferenceGroupControl对象上的value()方法一样简单,以获取底层的引用值(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


最后要注意的一点是,我相信可以通过操纵数据源对象而不是formcontrol对象来获取值。我过去在搜索谷歌搜索结果时看到过类似的解决方案。如果我再次遇到它们,我将更新答案

,以防我们解决了错误的问题,更简单的方法可能是引用表/数据源方法
SalesTable.DeliveryPostalAddress
(用作RefGroupControl)有一个方法
SalesTable.deliveryAddress()
,您可以调用该方法。我无法使用text()获取值,是不是因为我的引用组控件下面没有StringEdit?我无法从datasource获取数据,因为我想要表单上输入的值,它可能是数据库中不存在的脏值,对吗?您可以显示一个带有参考组的屏幕截图吗?如果是参与方引用组,则必须具有StringEdit控件;如果不是,这就解释了为什么
valueStr()
不起作用。@CSL text()调用的原因很简单,因为在我的示例中,当您拖放引用组控件并将替换字段组属性设置为(默认)AutoIdentification时,MorpX设计器创建的子控件是StringEdit控件。根据您的情况,您应该了解在参考组中自动创建的子控件。正如Aliaksandr所说,共享表单的屏幕截图,我们将能够指出正确的方法调用。我添加了一个屏幕截图,当我直接将party字段拖到设计中时。