Monday, March 18, 2024

How to Fix the Error: “A Reference Is Required to Compile This Module” In Dynamics 365 Finance and Operations

Error: A reference to 'Dynamics.AX.ApplicationFoundation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is required to compile this module. CUSModel (VAR) [CUS]

This error indicates we’re trying to modify/reference code from a model (Application Foundation) other than the current model (CUS) and a reference isn’t set up between the two. 

To fix this error, navigate to Dynamics 365 > Model Management > Update model parameters.



Select the current model. The model name is “CUS” in this case. The details related to the model will be populated on the “Update model parameters” form.



Now click Next and select the model that needs to be referenced.



Once all the related models are selected, click Next and follow the dialog.

Tuesday, March 12, 2024

Data Retrieval from Various Tables via HcmWorker in Dynamics 365 Finance and Operations

Get HcmWorker Table from Personnel Number: 

HcmWorker hcmWorker = HcmWorker::findByPersonnelNumber('00001');

Get Active HcmEmployment Table from HcmWorker Record Id:

HcmEmployment hcmEmployment = HcmEmployment::getActiveEmploymentsByWorker(hcmWorker.RecId);

Get DirPerson Table from HcmWorker:

DirPerson person = hcmWorker.DirPerson();

Get DirPersonName Table from DirPerson Record Id:

DirPersonName dirPersonName = DirPersonName::find(person.RecId);

Get HcmPersonPrivateDetails Table from DirPerson Record Id:

HcmPersonPrivateDetails personDetails = HcmPersonPrivateDetails::findByPerson(person.RecId);

Get HcmPositionWorkerAssignment Table from HcmWorker Record Id:

HcmPositionWorkerAssignment positionWorkerAssignment = HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(hcmWorker.RecId);

Get HcmPositionDetail Table from HcmPositionWorkerAssignment Position:

HcmPositionDetail hcmPositionDetail = HcmPositionDetail::findByPosition(positionWorkerAssignment.Position);

Get HcmPositionHierarchy Table from HcmPositionWorkerAssignment Position:

HcmPositionHierarchy positionHierarchy = HcmPositionHierarchy::findByPosition(positionWorkerAssignment.Position);

Get HcmPositionWorkerAssignment Table from HcmPositionHierarchy ParentPosition:

HcmPositionWorkerAssignment parentPositionWorkerAssignment = HcmPositionWorkerAssignment::findByPosition(positionHierarchy.ParentPosition);

Get LogisticsPostalAddress Table from DirPerson Record Id:

LogisticsPostalAddress logisticsPostalAddress = DirParty::primaryPostalAddress(person.RecId);

Get HRMCompFixedEmpl Table from HcmWorker Record Id and HcmPositionWorkerAssignment Position:

HRMCompFixedEmpl fixedCompensation = HRMCompFixedEmpl::findMostRecentFixedCompensation(hcmWorker.RecId, positionWorkerAssignment.Position);

Get JmgEmployee Table from HcmWorker Record Id:

JmgEmployee jmgEmployee = JmgEmployee::find(hcmWorker.RecId);

Get HcmPersonDetails Table from DirPerson Record Id:

HcmPersonDetails hcmPersonDetails = HcmPersonDetails::findByPerson(person.RecId);

Get HcmPositionType Table from HcmPositionDetail Position Type:

HcmPositionType hcmPositionType = HcmPositionType::find(hcmPositionDetail.PositionType);