Skip to main content

Notifications

Announcements

No record found.

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

How to add range to data entity?

(0) ShareShare
ReportReport
Posted on by 735
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... 291,904 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 735 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 230,605 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
    Shooowtek 735 on at
    How to add range to data entity?
    Does anyone have a suggestion?
  • Shooowtek Profile Picture
    Shooowtek 735 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,587 Super User 2024 Season 1 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 230,605 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,904 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,605 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans