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.
ref link - https://stackoverflow.com/questions/57508423/how-to-get-value-of-formreferencegroupcontrol