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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

X++ code auto filter purchase order lines V2 from Open In Excel on PurchOrderListPage

(5) ShareShare
ReportReport
Posted on by 14
Hi,
 
I need to add a filter for a custom data entity to behave the similar as Purchase order line V2 data entity when Open In Excel from purchOrder form PurchOrderListPage.
When downloaded excel file is opened. The filter of purchID has automatically set from Purchase order header as screenshot attached.
Where can I find the X++ code in AOT? So I can refer to it as reference.
 
Thanks,
 
Huan
Categories:
I have the same question (0)
  • Navneeth Nagrajan Profile Picture
    2,538 Super User 2026 Season 1 on at
    Hi YC-19120037-0,
     
     
    A few suggestions:
    1. Would recommend you create an export project in Data management and have the purchase order lines v2 exported onto an Excel or a CSV file and then filter the purchase orders onto an excel spreadsheet.
    2. Its a bit strange to filter out purchase orders and then download it onto an excel file and open it. Would rather recommend filtering the purchase orders on the excel spreadsheet itself.
     
    However, if the above suggestion is not valid as per your business requirement, then would recommend using the getDataEntityContext() method and use the ExportToExcelDataEntityContext class based on the menu item selected which in this case is the OfficeGeneratedExportMenuItem.
     
    Hope this helps. Happy to answer questions, if any.
     
  • YC-19120037-0 Profile Picture
    14 on at
    Hi Navneeth,
     
    Thanks for the suggestions.
    I did try the same following purchTable.xpp to use getDataEntityContext() method and use the ExportToExcelDataEntityContext class for OfficeGeneratedExportMenuItem. However it did not even generate Open in excel option. I doubt it is for Export to excel not Open in excel. 
    I can see Open In Excel menu gets generated if I use officeHelper.OfficeMenuInitializing for the eventHandler OnInitializing of the form.
     
    I am wondering how OOTB purchTable form did that and I would like to do the same. Unless this piece of the code with office integration for OData is not exposed in AOT.
     
    Thanks again.
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,538 Super User 2026 Season 1 on at
    Hi YC-19120037-0,
     
    Open in Excel functionality in D365 FO leverages the OData framework that uses the client side Excel Add-ins. Open in Excel on the Purch Order form applied a filter on the PurchId field from the PurchOrder form. and applies to based on other fields like DataAreaId. 
     
    For custom entity, you can use the following steps:
    1. Use Document templates form, create a template for the current custom entity and then check "Apply current record filter".
    2. You can use overriden form methods like registerTemplate() for the filters to be applied based on the selections being made. 
     
    Search for DocuTemplateRegistrationBase in AOT and you should be able to see a standard entity like PurchPurchaseOrderLineV2Entity that have system templates with "Apply current record filter" enabled. This determines the filtering parameters.
     
    Hope this helps. Happy to answer questions, if any.
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    303,706 Super User 2026 Season 1 on at
    Hi Huan,
     
    You can find the example X++ coding to set filters for the Export to Excel feature on the PurchTable form. Check the next form methods:
    • customizeMenuOptions
    • getDataEntityContext
    • getInitialTemplateFilters
    • updateTemplateSettings

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans