Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to add range to da...
Finance forum
Suggested answer

How to add range to data entity?

Posted on by 672
Hello,
 
I created a data entity for the standard PriceDiscTable. When a user goes to form purchase prices for a particular vendor, he wants the data entity to be filtered by vendor number when retrieved in excel.
My question is: How do I add a filter to the data entity for the currently selected vendor?
 
I tried to follow the standard entity PurchPurchaseOrderLineV2Entity which in excel has a range of currently open purchase order.
I wrote something like this and I created range to AccountRelation in main datasource:
 
 
public class myPriceDiscTableEntity extends common
{
    public static void addChangeTrackingDataSourcesForMyPriceDiscTableEntity(QueryBuildDataSource _parentDS, FieldId _parentAccountRelationFieldNum, JoinMode _joinMode)
    {
        var priceDiscTableDS = _parentDS.addDataSource(tableNum(PriceDiscTable));
        priceDiscTableDS.joinMode(_joinMode);
        priceDiscTableDS.addLink(_parentAccountRelationFieldNum, fieldNum(PriceDiscTable, AccountRelation));
        myPriceDiscTableEntity::defaultCTQuery();
    }
    
    public static Query defaultCTQuery()
    {
        Query PriceDiscTableQuery = new Query();
        var priceDiscTableDS = PriceDiscTableQuery.addDataSource(tableNum(PriceDiscTable));
        priceDiscTableDS.addRange(fieldNum(PriceDiscTable, relation)).value(queryValue(PriceType::PricePurch));
        return PriceDiscTableQuery;
    }
}
Unfortunately with no results..
 
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,142 Super User 2024 Season 2 on at
    How to add range to data entity?
    Hi Shooowtek,
     
    There is an example in Dynamics 365 when opening journal lines in Excel. It will then also pass a record as a filter. You can find code that you can use as example in the class method LedgerJournalFormTable::openExcelTemplate().
  • Shooowtek Profile Picture
    Shooowtek 672 on at
    How to add range to data entity?
    Hello Martin,
    Sorry, my mistake. I was referring to the vendor all along.

    As I already wrote. I want the user, after clicking "Open in Excel" and downloading the excel file, to have a filter already created with the vendor account number.
     
    Filter in this section below:

    Thank you.
  • Martin Dráb Profile Picture
    Martin Dráb 227,979 Super User 2024 Season 2 on at
    How to add range to data entity?
    If you want Open in Excel, then the answer to my first question is no (you don't want Export to Excel). These are two different things. It would be good to clarify what is the actual business requirement and what is just your decision regarding implementation (which may be changed, as long as the solution solves the business problem).
     
    Regarding the vendor number and purchase prices, does it mean that you talked about customers (e.g. "entity to be filtered by customer number") by mistake?
  • Shooowtek Profile Picture
    Shooowtek 672 on at
    How to add range to data entity?
    Does anyone have a suggestion?
  • Shooowtek Profile Picture
    Shooowtek 672 on at
    How to add range to data entity?
    Yes, the user clicks "Open in Microsoft Office" and then "Open in Excel" and downloads the excel file with data entity.

    The requirement is that the data entity already has a range created with the vendor number,
     
    The path where the user downloads the excel file: Accounts payable > Vendors > All vendors > (specific vendor) > Purchase prices
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,532 Moderator on at
    How to add range to data entity?
    Your question is not clear for me. When you say,
     
    'When a user goes to form purchase prices for a particular customer, he wants the data entity to be filtered by customer number when retrieved in excel.' 
     
    This point is not clear to me. Are you saying on click on Open in Microsoft office and then > Open in Excel or Export to Excel you are saying? If yes, then as per standard the entity works in such a way that whatever the records are shown then those can be shown in excel.
     
    If you are saying about normal data management entity, then by standard we have filter option.
  • Martin Dráb Profile Picture
    Martin Dráb 227,979 Super User 2024 Season 2 on at
    How to add range to data entity?
    Please tell us more about your scenario.
     
    Do you want to use Export to Excel feature?
     
    Do you mean that this particular export menu item should work only if the selected record is related to a customer (no vendors, customer groups etc.) and it should include all price/disc records also linked directly to the same customer? Or those applicable to the given customer (e.g. through a customer group)?

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,142 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,979 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans