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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

.Net Interop

(0) ShareShare
ReportReport
Posted on by

Hi all,

I have followed this guide to get the object name. But when I run the following line.

MESSAGE('%1 %2', CurrentObject.ID, CurrentObject.Type);

I only get a '0' returned in the message.

I have downloaded his zip at the bottom of the page. 

 

I use NAV2016. How can I make it work? Or is there another way to get the name of the current codeunit you are in?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello Christopher007,

    In NAV 2016 first you have to Re-declare the Dot Net variables,

    After that compile the codeunit, once successfully compiled then create a new code unit and in that declare a variable of imported codunit i.e. Codeunit 86832 "Current Object Management".

    In that codeunit write the following code.

    MESSAGE('%1 %2',CurrentObjectManagement.Type,CurrentObjectManagement.ID);

    Now save, compile, run, you will get definitely result.

  • Community Member Profile Picture
    on at

    Re-declare Dot Net variables? How can I do that?

    What I did:

    Imported the codeunit, compiled it, made a new codeunit with global variable datatype codeunit to the imported codeunit. OnRun I wrote the same you did.

  • Suggested answer
    Community Member Profile Picture
    on at

    Open the codeunit that you imported. Further go to design > Click View - C/AL Globals.  

    Here you will get all the Global Variables. Remove all the SubType and again select the proper value. Compile the Codeunit and see if it works.

  • Community Member Profile Picture
    on at

    What if I am not able to find the first global variable subtype on the list. Its not displayed, but I already have it from when I imported it.

    System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

  • Suggested answer
    Community Member Profile Picture
    on at

    Copy that value in Subtype. Delete the value in subtype and again paste it in subtype. See if it work.

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello,

    Go thru as per Vishal suggestions,

    And you have to do for all DotNet variables, In this codeunit also some functions contains Local dotnet variables, that variable you have to do also.

    See the bellow screenshot for demo purpose.

    Variable-declare.png

    Variable-declare.png

  • Community Member Profile Picture
    on at

    Its still not helping making it work, but thanks for showing me how to re-declare the variables. I will try again tomorrow and see if I can make it work, else I will try find another way.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans