Learn to Use a Label Creator Add-in Extension in Dynamics 365 for Finance & Operations

by | Updated April 3, 2018 | Development, Dynamics 365 for Finance and Operations

Creating labels has always been considered a chore by developers, and the task hasn’t really gotten any easier with Dynamics 365. Wouldn’t it be nice if you could type your value into the property and let Visual Studio move it to a label file? Luckily, we can. I’ll show you how to use the label creator Add-in extension in Dynamics 365 for Finance & Operations.

Start by creating a new Dynamics 365 Developer Tools Add-in project.

Create new Dynamics 365 Developer Tools Addin project

This will create a new class library project that contains two source files. The first, DesignerContextMenuAddIn.cs, contains boilerplate code for creating a designer add-in. The second, MainMenuAddIn.cs, contains a menu add-in.

Label Creator Addin Extension

The first thing we will need to do is to add a few references to our project:

  • C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\
    • EnvDTE.dll
    • EnvDTE80.dll
  • C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\5hutepyf.xp2\
    (Your folder may vary slightly)

    • Microsoft.Dynamics.Framework.Tools.LabelEditor.dll
    • Microsoft.Dynamics.Framework.Tools.ProjectSystem.dll
    • Microsoft.Dynamics.Framework.Tools.ProjectSupport.dll
  • C:\AOSService\PackagesLocalDirectory\bin\
    • Microsoft.Dynamics.AX.Metadata.dll
    • Microsoft.Dynamics.Framework.Tools.AutomationObjects.dll

Our designer’s context menu is controlled by the DesignerMenuExportMetadata attribute on the class. You can see in the screenshot that by default our add-in will appear in both the Form and Table designers.

The OnClick method is called when the user clicks on our menu. We will modify this method to convert the text contained in the Label property to an actual label. To do this, create regular expression to distinguish between a label identifier and a normal string.

Lastly, open the resource file and change the DesignerAddinCaption. This value will appear in the context menu item.

DesignerAddinCaption

To test your add-in, press F5 and Visual Studio will build your project and copy the dll to the appropriate folder. On my computer, the add-in folder is at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\5hutepyf.xp2\AddinExtensions\.

Create a Dynamics 365 Unified Operations project.

Unified Operations project

Add a new table to the project.

Add a new table to the project

Add a label file.

Add a label file

Open your table in the designer and type a value into the Label property.

Type a value into the Label property

Right-click the table node in the designer and move your mouse to the Add-ins menu.

Addins menu

Click the Create labels option and your add-in will create a label resource and update the Label property.

Label property

Label property

 

Related Posts

4 Comments

  1. Fayt

    Hello Mark,

    I have an error while trying to add the source code into the relevant class. The compiler error is indicating that it cannot find a definition for DesignerContextMenuAddIn.Context. A google search of DesignerContextMenuAddIn.Context did not help out neither. Could you point me, or anyone else trying this out to work?

    Thanks in advance.

  2. Taylor Valnes

    Hello Fayt,

    I’ve spoken with Mark on this and he noticed that there are two static members missing from the class. They are listed below.

    static DTE2 MyDte => CoreUtility.ServiceProvider.GetService(typeof(DTE)) as DTE2;
    static VSApplicationContext Context => new VSApplicationContext(MyDte.DTE);

    Regards,
    Taylor

  3. Attila Ban

    Hi Mark,

    Brilliant stuff, massive thank you for writing about it! The label editor is a massive pain point for me, indeed!
    Tried following your footsteps, but got some issues.

    When created the blank project, it immediately have had reference issues (6-7 references were not found).
    I managed to find most, but Microsoft.Dynamics.Framework.Tools.Extensibility.dll

    Any chance where can I find it?

    I’m working on an upgraded 7.2 PU12 (to PU15) OneBox dev environment.

    Many thanks in advance,

    Kind regards,
    Attila

  4. Dalton Roll

    Hello Attila,

    I spoke with Mark and the following was his response:

    “You will have to search your hard drive for the location of the assembly. I’m now on 8.0, and mine was found in the add-in folder, C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\agk3do44.e2i\Microsoft.Dynamics.Framework.Tools.Extensibility.dll.”

    Regards,
    Dalton

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

september

02sep10:00 am10:30 amThe Modern Manufacturer - Cycle Count Management

02sep12:00 pm12:30 pmBest Practices for Work Order Planning and Routing for Field Service Companies

09sep10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

09sep12:00 pm12:30 pmOverview of Microsoft Promotion for NAV and GP Clients

10sep11:00 am12:00 pmConfab with Stoneridge - Livestream - Field Service Comparisons

16sep10:00 am10:30 amThe Modern Manufacturer - Product Lifecycle Management

16sep12:00 pm12:30 pmHow to Upgrade to Dynamics 365 Finance and Operations: Examining Custom Code and ISV Implications

16sep2:00 pm2:30 pmScheduling and Dispatching for the Modern Field Service Company

23sep12:00 pm1:00 pmDynamics 365 Business Central Wave 2 Release Preview - An Overview of the Most Exciting New Features Coming in October

24sep11:00 am12:00 pmConfab with Stoneridge - Livestream - The Modern Workplace: Teams, Sharepoint, Outlook, Office, and AI Integration

30sep10:00 am10:30 amThe Modern Manufacturer - Return Management

30sep12:00 pm12:30 pmEmpowering Your Field Service Technicians with a Mobile Solution

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Orders

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X