web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Relation in data entity

(0) ShareShare
ReportReport
Posted on by 209

Hi Community Fellows,

I have added a new Field in HcmPositionDetail Table called "ARParentDepartment" and created a new relation with "OMOperatingUnit" table as well.

pastedimage1653476701476v1.png

Now I want to add this field in "HcmPositionDetailEntity" as well but I want to expose it as a Parent department number field instead of a Parent department RecId so that we can use that column for data update/insertion through excel Add-in.

I have created an extension of "HcmPositionDetailEntity" and added the "ARParentDepartment" recid in its fields but I am stuck on transforming it into a department number field.
I have an existent Department Rec Id and Department Number field in the "HcmPositionDetailEntity" already.

pastedimage1653477125831v2.png

I have tried creating a same relation in the "HcmPositionDetailEntity" but the entity is showing the same data in ARParent department number column as of the existent department number column.

pastedimage1653477270000v3.png

The requirement is to have a column of Parent department number which displays department numbers based on the Recids present in the ARParentDepartment field of data entity.

Looking forward to usual helpful responses.

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Relation in data entity D365FO

    Hi Ali,

    The best example for this will be to look at CaseDetailBaseEntity. As in this entity, you will need to join OMOperatingUnit as a read-only datasource to HcmPositionDetail based on the new field you created.

    pastedimage1653481665847v1.png

    The field ARParentDepartment in your case should be added to the entity with "Access modifier" property set to Private, as is the case with Department field.

    pastedimage1653481753094v2.png

    You will need to add OMOperatingUnitNumber from OMOperatingUnit into the data entity fields.

    pastedimage1653481836268v3.png

    Finally, the data entity relation will be based on the field created above with OMOperatingUnitEntity.

    pastedimage1653481933781v4.png

    This should take care of your requirement to show the Department number and also update the Department number.

  • alinawaz Profile Picture
    209 on at
    RE: Relation in data entity D365FO

    Hi Gunjan Bhattachayya 

    I have followed your instructions but the data in SQL is still the same after build and sync.

    I added the "ARParentDepartment" RecId in the entity and marked the access modifier private.

    pastedimage1653486107677v1.png

    Then I added a new Mapped field named as "ARParentDeptNumber" in the data entity fields


    pastedimage1653486286836v2.png

    After this I have added a new foreign key relation

    pastedimage1653486500581v3.png

    In the relation properties I was unable to the "OMOperatingNumber" column so I have typed it manually.

    pastedimage1653486571058v4.png

    After doing all these steps, I am still seeing the same data in ARParentDeptNumber and Department number column in SQL.

    pastedimage1653486666461v5.png

    Maybe I am doing something wrong here ?

    P.S: There's one Department number column already present in entity and it has the same relation with OMDepartmentEntity, I tried replicating the same relation but its also returning same data in SQL in both columns (ARParentDepartment Number & Department Number ).

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Relation in data entity D365FO

    Hi Ali,

    I didn't check the entity that you are extending. In your case, since OMOperatingUnit is already included in the data source, you will need to add another data source with a different name (OMOperatingUnit_Parent for an example). This data source will be linked based on the ARParentDepartment field - HcmPositionDetail.ARParentDepartment  == OMOperatingUnit_Parent.RecId.

    From the screenshots you have shared, I can see that you are using the existing data source OMOperatingUnit, which is linked based on the field Department from HcmPositionDetail table.

  • alinawaz Profile Picture
    209 on at
    RE: Relation in data entity D365FO

    Thanks a bunch Gunjan Bhattachayya

    It worked :)

    You are a real life saver.

    Best Regards.

  • alinawaz Profile Picture
    209 on at
    RE: Relation in data entity

    Hi Gunjan Bhattachayya 

    I am facing an issue while performing a full DB sync.

    pastedimage1653646601146v1.png

    When I perform Sync from the project there are no issues, this error only appears on full DB sync.

    Any idea where shall I look for the solution of this ?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Relation in data entity

    Hi Ali,

    Could you try a full build of your Dev model and if there are no errors, do the DB synchronize?

  • alinawaz Profile Picture
    209 on at
    RE: Relation in data entity

    Yes I have build the model and it has no errors


    pastedimage1653647328034v1.png

    But still getting the error in full sync

    pastedimage1653647779012v2.png

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Relation in data entity

    Could you share screenshot(s) of the changes you have made in the entity extension? I will try to replicate them at my end and see if I get the same error while synchronizing.

  • alinawaz Profile Picture
    209 on at
    RE: Relation in data entity

    1 - Created extension of HcmPositionDetail Entity And added ARParentDepartment field in the data entity fields

    pastedimage1653648487867v1.png

    2 - Added a new data source OMOperatingUnit to create a Parent department number field.

    pastedimage1653648620934v2.png

    3- Added a new relation in the newly created data source OMOperatingUnit

    pastedimage1653648682190v3.png

    4- Then added a new Mapped field inside the fields node of data entities, ARParentDeptNumber 

    pastedimage1653648778599v4.png

    5- Then I have also added a relation in the relation node of Data entity.

    pastedimage1653648853452v5.png

    I have my suspicion on this step, when I was creating the relation no column name was appearing in the RelatedField property. But I wrote the column name manually there to complete the relation. I was looking at the existent Department relation and choose all same properties in the relation I created.

    pastedimage1653648990744v6.png

    After all of these changes in Data entity, I created an extension of HcmPositionDetailStaging Table and added the ARParentDepartment field in it too.

    pastedimage1653649143459v7.png

    These are all the steps I have performed. And If I build and sync the project there are  no errors. The error only occurs in full DB sync

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Relation in data entity

    Hi Ali,

    I tried the same changes and didn't face any issues with DB synchronization. I also didn't get the drop down for fields for OMOperatingUnitEntity. One thing you can try changing is the Role property in the "parentDept" relation.

    pastedimage1653697440158v1.png

    Role name "PostionDetails" already exists for the Department relation. If this doesn't solve the issue, you can try a full build of the application and see if that helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 650 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#3
CU05031448-0 Profile Picture

CU05031448-0 526

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans