Blog title card with an Excel spreadsheet and Business Central icon reading Implementing Edit in Excel from Business Central.

Implementing Edit in Excel from Business Central

2 min read

The Edit in Excel action is available on most lists. With the Edit in Excel action, you make changes to records in Excel and then publish the changes back to Business Central. This blog will guide you through the steps needed to implement and effectively use the Edit in Excel functionality in Business Central.

❌ This functionality is only available on Business Central cloud environment.


“Edit in Excel” implementation

You can add it to any page in Business Central. For our example, we will use the Sales Price List and focus on the lines sub-page Price List Lines.

Sales Price List page in Business Central with the Lines action menu showing Open in Excel.

As you can see currently, it has only Open in Excel procedure, which opens the data in Excel but not Edit in Excel. I will show you now how easy it is to add it.

To implement, we need following codeunit:

EditinExcel: Codeunit "Edit in Excel";

It should look like this:

AL pageextension code that adds an Edit in Excel action and calls EditPageInExcel for Price List Lines.

Let’s publish and check the Sales Price List page now:

Sales Price List page with the Lines menu expanded, showing Open in Excel and Edit in Excel options.

Action is shown after Open in Excel and now it doesn’t only open the data, but it also allows you to edit and sync back to Business Central.

This is not fully correct for now, you will need to filter data received, otherwise it will show you Price List Lines for all Price Lists!


Filter data being received to Excel

If you need to filter the data before it gets sent to Excel, you will need to use procedure AddFieldV2 from Edit in Excel Filters codeunit.

We need to filter data for specific Sales Price List:

AL OnAction trigger code that adds an Edit in Excel filter for Price_List_Code before calling EditPageInExcel.

Field Price List Code is added as Edit in Excel Filter, so it shows only Sales Price List Lines for the Price List that you have opened and not for all Sales Price List Lines. This is most commonly used on Card Pages where “Edit in Excel” is implemented.

❌ Method AddField is obsolete from version 25.0. Use AddFieldV2 instead.


Excel exported File name

I would recommend to change file name of Excel which is being exported, otherwise it would be default:

Download notification showing an exported Excel file named Lines.xlsx.

In order to do that, define additional Label and add it as last parameter in EditPageInExcel procedure.

AL code adding ExcelFileNameTxt and using StrSubstNo to set a custom export file name.

The result:

Download notification showing a custom export file name: Price List S00001 - Lines.xlsx.


Visibility for SaaS

As already mentioned, on beginning of this blog post, this functionality is only available for SaaS. That’s why it’s also recommended to add visibility property to the action.

Declare variable for visibility property:

AL variable declaration for IsSaaSExcelAddinEnabled as a Boolean used for action visibility.

Check if Environment is SaaS on the trigger “OnOpenPage”. To do that use method GetIsSaasExcelAddinEnabled from Server Setting codeunit.

AL OnOpenPage trigger that sets IsSaaSExcelAddinEnabled using ServerSetting.GetIsSaasExcelAddinEnabled().

And of course, add Visible property to action parameters:

AL EditInExcel action definition with Visible bound to IsSaaSExcelAddinEnabled.


By the way, you don’t need to add “Edit in Excel” on Price List Lines page anymore, this is my contribution to Business Central Base Application and will be implemented in the next release:

https://github.com/microsoft/BusinessCentralApps/pull/1019

Additionally you can read more about how “Edit in Excel” is working from functionality side on YZhums blog: Dynamics 365 Business Central: How to use Edit in Excel in the browser/web (Excel Online) | Dynamics 365 Lab

Hope you find this useful and stay tuned for more! 🚀

Related posts

1 comment

  • zoritoler imol

    As a Newbie, I am continuously exploring online for articles that can be of assistance to me. Thank you

Leave a comment

Reviewed before it appears.