Getting a Value from reference Group

hi i am using dyanmics ax 2012.

I want to keep a validation on a field by fetching its value but the control on the form is Reference group control.

How do i fetch value from it?

I tried using ValueStr() and value but not getting the exact value in the field.

#Define.controlName(TestControl)

FormReferenceGroupControl testReferenceControl = Grid.addControl(FormControlType::ReferenceGroup, #controlName);

testReferenceControl.dataSource(tableStr(testDataSourceTable));

testReferenceControl.referenceField(fieldNum(testDataSourceTable, testField));

testReferenceControl.visible(false);

is it a macro?

Where do i have to write this code?

FormReferenceGroupControl.value() returns the reference. If you’re interested in a replacement value, find a record by the reference and get other fields from the record.

on this form InventNonConformanceTableCreate i am having the field worker responsible.(Which is a reference group)

on click of ok

i want to check that the value in that field is not null.

even if i have selected nothing i am not getting null value instead i am getting some number

i tried

a =reportedBy.value();

info(strFmt("%1",a));

if(a ==0)

{

warning(‘The field “reportedby” cannot be blank’);

}

or by valuestr() but not able to get the reference or value.

what should i do?

i am using ax 2012 r2

You’re looking at a wrong field - Worker responsible is CreateInformation_TestResponsibleWorker control. Because the control is bound to a field, access it through the data source, i.e. inventNonConformanceTable.TestResponsibleWorker.

By the way, Reported by is initialized automatically in the init() method, therefore it has a value even if you never choose it manually.

Thanks Martin You saved the day…