Reputation: 75
In D365 form development, I like to get the value entered to the form control, the form control is a form reference group control with Party reference field.
How to get the value entered to the control ?
tried with:
ReferenceGroup.controlNum(i).valueStr();
FieldBinding with filterValue
both also not work.
Upvotes: 1
Views: 6071
Reputation: 1090
It should be as simple as calling the value() method on the FormReferenceGroupControl object to get the underlying Reference value (int64) which is the RecId of the underlying datasource. For example:
FormReferenceGroupControl referenceGroupControl;
referenceGroupControl = element.control(element.controlId(formControlStr(ReferenceGroupTestingForm, ReviewHeaderInfo_CustomsRepRefGroup))) as FormReferenceGroupControl;
referenceGroupControl.value(); //returns the RecId of the DirPerson table displayed.
To get the Display value which is substituted to the user instead of the underlying RecId value stored in the database, do this:
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
One last thing to note is that I believe it is possible to get the values by manipulating datasource objects instead of formcontrol objects. I have seen solutions like this in the past while hunting through google search results. If I encounter them again I will update the answer
Upvotes: 3