Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

ReadOnly data entity

(0) ShareShare
ReportReport
Posted on by 1,550

Hi,

If we want to import using DMF, does all entity datasources require to be is Read only No? Or some of them needs to be No?

What does this property do?

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: ReadOnly data entity

    If you implement it correctly, it'll be done automatically by DMF. Also, you can do it by yourself, if you're so keen to do it in code.

  • junior AX Profile Picture
    junior AX 1,550 on at
    RE: ReadOnly data entity

    If I fill party number... How is Number field going to be filled?

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: ReadOnly data entity

    I mention two approaches - you'll either use RecId or the natural key (Name + PartyNumber).

  • junior AX Profile Picture
    junior AX 1,550 on at
    RE: ReadOnly data entity

    Hi Martin,

    I didn't say table1.Name is enough...but didn't you say in the previous reply that I should use dirPartyTable.PartyNumber instead of table1.Number

    So if I understood you correctly..the entity key should contain table1.Name and DirPartyTable.PartyNumber (in addition to other tables of course)

    Or did I not understand you correctly.

    Also what do you mean by expose table2.table1RecId  without having table1 in the entity....in which method shall I fill this? How can I fill it by code?

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: ReadOnly data entity

    Knowing just table1.Name isn't enough to identify a record in table1 because - according to what you told us before - the unique key of table1 is the combination of Name and Number. But if know RecId, you don't need to find it. You can either expose table2.table1RecId (and not having table1 in the entity at all), or use natural keys, as discussed above.

  • junior AX Profile Picture
    junior AX 1,550 on at
    RE: ReadOnly data entity

    Hi Martin,

    So you mean I should replace the number field in the entity key with DirPartyTable.PartyNumber?

    So the entity key should be like this now:

    FieldX from table3

    FieldY from table3

    Field1 from table2

    Name from table1   -- how to fill this by code as I already know table1.Name value

    DirPartyTable.PartyNumber

    but how is table1.Number is going to be filled if I don't import it?

    Regarding this: "but how could this happen if you had no information about which table1 record should be used? It really requires field(s) identifying table1 records."

    As I said, I'm importing the entity through code, the caller for the button I'm using to import is table1, this means I have Table1.RecId and I can use it to fill Table2.Table1RecId. But the question is how?

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: ReadOnly data entity

    You finally started adding a lot of information that you should have started with. You can't expect us to know what you don't even mention.

    If table1.Number is a foreign key of DirPartyTable, you can join table1 in your entity with DirPartyEntity and use PartyNumber instead of table1.Number.

    Therefore you'll use table1.Name and DirPartyEntity.Number to identify records in table1, and these two fields needs to be in the entity key.

    Your statement that "Field1 in table2 is unique" means that it can be used to identify table2, but the same isn't true about table1, which is what I was talking about. You said that "once Table2 record is inserted then this means Table2.Table1RecId field is inserted", but how could this happen if you had no information about which table1 record should be used? It really requires field(s) identifying table1 records.

  • junior AX Profile Picture
    junior AX 1,550 on at
    RE: ReadOnly data entity

    Hi Martin,

    Regarding this "Anyway, RecId of which table do you store in table1.Number"

    Table1 has 2 fields, Name and Number -- number is Party in dirPartyTable which is int64 -- and there is also the recId for the table of course.
    the relation between table2 and table1 is Table2.Table1RecId = Table1.RecId

    Regarding this: "You should use the natural key of the table in the entity"

    As i told you the unique index for table1 is Name and Number -- so what should i do here?

    Regarding this: "Also, can you confirm that table1 may contain Number several times (with different names)?"

    Yes.

    Regarding this: " Neither field1 nor table2RecId identifies a record in table1"

    How come? Field1 in table2 is unique and I'm importing through code by clicking on a button where the caller is Table1.
    once Table2 record is inserted then this means Table2.Table1RecId field is inserted.
    Since the relation between table1 and table2 is Table2.Table1RecId = Table1.RecId --- then can't i get the unique record of table1?

    I can gurantee to you that we always create records in table2 where table1 is already inserted -- that's why i want table1 to be read only.

    So we shouldn't be able as well to change Table2.Table1RecId


    So do you think this key is right now? unless you meant sth when you said earlier sth about natural key

    FieldX from table3

    FieldY from table3

    Field1 from table2

    Name from table1   -- where i fill this by code because i should have it already

    Number from table1 -- where i fill this by code because i should have it already

    if you think the key is correct?  the question is how can i fill Name and Number by code

     

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: ReadOnly data entity

    We shifted compeltely from the question whether "all entity datasources require to be is Read only No".

    Anyway, RecId of which table do you store in table1.Number? You should use the natural key of the table in the entity.

    Also, can you confirm that table1 may contain Number several times (with different names)?

    No, I disagree with your statement " if I have field1 from table2 which is imported by the user and I have table2RecId from code...this means I can get the value of name and Number fields for table1 based on the relation between table1 and table2". Neither field1 nor table2RecId identifies a record in table1. If you identify an existing record in table2, you can get information about currently related table1, but this doesn't cover all scenarios. It doesn't help you when creating new records in table2 or changing Table1RecId.

  • junior AX Profile Picture
    junior AX 1,550 on at
    RE: ReadOnly data entity

    Hi Martin,

    So if made the Entity Key like this:

    FieldX from table3

    FieldY from table3

    Field1 from table2

    Name from table1

    Number from table1

    I'm sure that the combination of these is unique.

    Now if I have field1 from table2 which is imported by the user and I have table2RecId from code...this means I can get the value of name and Number fields for table1 based on the relation between table1 and table2

    So based on your answer in 2c what is the best method to populate these fields?

    Also does the idea I wrote works?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans