Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to develop a DotNet server-side add-in like the one used in Codeunit 9510

Posted on by Microsoft Employee

Hi,

Apologies if this has been questioned or answered before, but couldn't find it in my search done earlier.

Looking at codeunit 9510 Document Service Management, we can see that the DotNet assembly variable named DocumentManagementHelper is first Reset and then methods can be called. We also see that DotNet variable DocumentService is instantiated through the DocumentServiceFactory.CreateService([service type]). Wondering if that "Reset" does the instatiating of a class, but surely the CreateService method seems to be doing it!

This is done from inside a codeunit like what I want to do, not from inside a page!

I am having serious trouble trying to develop a similar add-in in C# to do something else, from inside a codeunit. I'd need to determine certain string contents and then pass them as attributes (metadata columns) for a file at a time, stored in Sharepoint Online.

I did (and spent days!) looking at possibilities, tried public static class definitions to avoid instantiation, got issues to used the DocumentManagementHelper to provide the Credentials to connect to the SP server using the standard NAV document service definition, even bought advanced C/Al development books and all I found so far was client-oriented add-in development examples that rely on C# development of add-ins to use on NAV pages. Not in codeunits.

Sure that looking at codeunit 9510 we can determine that what I want to do must be possible.

Using NAV 2017 currently.

Help on this to put me on the right path would be warmly welcomed!

Cheers

*This post is locked for comments

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: How to develop a DotNet server-side add-in like the one used in Codeunit 9510

    To develop a .NET addin (dll) for NAV, you can create a C# class that performs what you want (with public methods that will be exposed to NAV). After that:

    1) Place the DLL in the Addins subfolder under the Service Tier folder

    2) In your codeunit, declare a variable of type = Dotnet, subtype = your addin (you can select it). Then, set RunOnClient = NO.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans