SBX - Search With Button

SBX - Forum Post Title

How to select data in DataEntity?

Dynamics 365 for Finance and Operations Forum

JustZM asked a question on 13 Jun 2019 5:16 PM
My Badges

Question Status

Suggested Answer

Hi Everyone

          This is my first time to create DataEntity Extension (A). In my the last post, I create an DataEntity Extension. Then I add one table(T) and one Entity(B) to be the datasource of A. Now the new DataEntity have some records are repetitive because they have different VaildFrom. 

How can I write code to select the newest VaildFrom if records are repetitive? And this is DataEntity Extension, how can I add my code to it?

Can I have some examples or references?

Thank you very much!

Best Regards,

JustZM

          

Reply

Can't you select records by validfrom descending ?

Reply
Suggested Answer

Hi JustZM,

Do you want to have just a single record with the latest ValidFrom date? In that case, instead of adding the datasource and include new fields, you can better include computed columns. docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

Reply
Pete Alberts responded on 14 Jun 2019 4:12 AM
My Badges
Suggested Answer

I assume the datasource is from a VTS source. The "duplicates" you mentioned are because of a one-to-many relation that occurs because of the VTS fact.

There is an option on the data entity datasource node named "Apply Date Filter". Set it to yes and then pull the ValidFrom and ValidTo fields into the data entity field list (you will get a compile time error if you don't).

Then when you query the data entity you should get only the current valid record from the VTS table. And no more "duplicates".

A good example is CustCustomerV3Entity: click Data Sources -> CustTable -> Data Sources -> DirPartyBaseEntity -> Data Sources -> LogisticsPostalAddressBaseEntity. Then notice the property "Apply Date Filter". Also DirPartyBaseEntity: DirPartyTable -> DirPersonForName -> DirPersonName

Kind regards

Reply
JustZM responded on 14 Jun 2019 1:44 PM
My Badges

Hi Sukrut

       What kind of method I can use for Entity Extension to select records by validfrom descending? I saw there are two function called "insertEntityDataSource" and "updateEntityDataSource". Can I use those two methods? If I can, how should I write code for it? Might I have some tricks for it?

Thank you very much!

JustZM

Reply

What joins you specified  in the datasource ? And what is the value specified on Entity datasource valid time state update property?

Reply
JustZM responded on 14 Jun 2019 2:14 PM
My Badges

Hi Sukrut

          I want to link two Entity "BankPositivePayExportEntity" and "VendorPaymentJournalLineEntity", so I followed link idea from "VendorPaymentJournalLineEntity" to add "LedgerJournalTrans" and "LogisticsPostalAddressBaseEntity" to "BankPositivePayExportEntity". I add some field from "LogisticsPostalAddressBaseEntity". 

          The Valid time State Update for both Datasources are "CreateNewTimePeriod"

Best Regards,

JustZM

Reply
Suggested Answer

Hi JustZM,

Do you want to have just a single record with the latest ValidFrom date? In that case, instead of adding the datasource and include new fields, you can better include computed columns. docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

Reply
Pete Alberts responded on 14 Jun 2019 4:12 AM
My Badges
Suggested Answer

I assume the datasource is from a VTS source. The "duplicates" you mentioned are because of a one-to-many relation that occurs because of the VTS fact.

There is an option on the data entity datasource node named "Apply Date Filter". Set it to yes and then pull the ValidFrom and ValidTo fields into the data entity field list (you will get a compile time error if you don't).

Then when you query the data entity you should get only the current valid record from the VTS table. And no more "duplicates".

A good example is CustCustomerV3Entity: click Data Sources -> CustTable -> Data Sources -> DirPartyBaseEntity -> Data Sources -> LogisticsPostalAddressBaseEntity. Then notice the property "Apply Date Filter". Also DirPartyBaseEntity: DirPartyTable -> DirPersonForName -> DirPersonName

Kind regards

Reply

SBX - Two Col Forum

SBX - Migrated JS