Greetings to everyone.
Right now I'm stuck or in a bind programming a reference group lookup field in a customized form for Dynamics 365 F&O.
I am creating a list page style form that will be displaying the summarized information for activities done by customers and assigned by employees. One of my columns is a reference group lookup field that has to display the name of the employee assigned to each activity, however, the field is showing in blank.
As a datasource to my customized form I added the smmActivities table, then, dragged and dropped the ResponsibleWorker field into a grid in my form. Furthermore, I checked into the properties of the field and set the Replacement Field Group selecting Person, which corresponds to the field group of the same name in the HcmWorker table. Moreover, the field ResponsibleWorker is a data type Int64 field that acts as the foreign key in smmActivities table to relate to the HcmWorker table.
In turn, I checked both the relationships, indexes, and properties in the HcmWorker table:
- For the replacement key property is set to HcmWorker_AK2.
- The index HcmWorker_AK2 is set as an alternate key allowing no duplicates. This key is composed of the fields: PersonnelNumber and Person.
- The Person field is a data type Int64 field that acts as the foreign key in HcmWorker table to relate to the DirPerson table.
- The Person field is assigned DirPartyRecId as its Extended Data Type property.
Following, I checked the properties of the EDT DirPartyRecId:
- Has DirPartyTable assigned as the Reference Table.
- The Node Table Reference has set the relation: DirPartyRecId == DirPartyTable.RecId
Having checked everything is in order, then I debugged my form to test if the lookup field was working, but the field was displaying blank values and it wasn't.
Next, I tried overriding the lookupReference method on my form's datasource field where I want to perform the lookup on with the following code.
public Common lookupReference(FormReferenceControl _formReferenceControl)
{
SysReferenceTableLookup sysReferenceTableLookup;
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
sysReferenceTableLookup = SysReferenceTableLookup::newParameters(tableNum(HcmWorker), _formReferenceControl);
sysReferenceTableLookup.addLookupMethod(tableMethodStr(HcmWorker,name));
query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(HcmWorker));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(HcmWorker, RecId));
queryBuildRange.value(queryValue(smmActivities.ResponsibleWorker));
sysReferenceTableLookup.parmQuery(query);
return sysReferenceTableLookup.performFormLookup();
}
Still, it is not working and the field still is displaying blank values.
I have researched and googled every article on the subject then tried each method, but the field is not working.
Hence, I am requesting anyone to point me out whether I missed something or used a wrong approach in order to get the desired result.