Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to add range to data entity?

(0) ShareShare
ReportReport
Posted on by 785
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
    294,914 Super User 2025 Season 1 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
    785 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
    233,716 Most Valuable Professional 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
    785 on at
    How to add range to data entity?
    Does anyone have a suggestion?
  • Shooowtek Profile Picture
    785 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
    3,634 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
    233,716 Most Valuable Professional 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)?

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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Martin Dráb Profile Picture

Martin Dráb 493 Most Valuable Professional

#2
Saalim Ansari Profile Picture

Saalim Ansari 310

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

Overall leaderboard

Product updates

Dynamics 365 release plans