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

Notifications

Announcements

No record found.

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 843
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..
 
I have the same question (0)
  • Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    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)?
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    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.
  • Shooowtek Profile Picture
    843 on at
    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
  • Shooowtek Profile Picture
    843 on at
    Does anyone have a suggestion?
  • Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    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
    843 on at
    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.
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,194 Super User 2025 Season 2 on at
    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().

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar 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... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans