AX / D365FO – How to get value of FormReferenceGroupControl

To get the RecId of the FormReferenceGroupControl

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s