
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