Run codeunits

elisiosousaelisiosousa Member Posts: 10
edited 2004-06-17 in Navision Attain
It's possible to run a codeunit outside navision?
for example: from a vb application?

Comments

  • janpieterjanpieter Member Posts: 298
    It's a quite popular question lately. Many posts are about this.

    Verry well:
    - yes you can, but you have to use "Navision Application Server" (NAS)
    - or use automation and create an event (trigger) in it, but this requires you to have a regular navision client open. And messages will appear wich blocks your VB code.
    In a world without Borders or Fences, who needs Windows and Gates?
  • elisiosousaelisiosousa Member Posts: 10
    thanks
  • elisiosousaelisiosousa Member Posts: 10
    a create a codeunit to capture the events from an automation object and run it.
    that automation object, afert insert a record, raises an event but the codeunit does'nt capture it.
    why so?
  • janpieterjanpieter Member Posts: 298
    Sounds like you are on the right way. One questions bothers me that i have never tried catching events in a codeunit, only on a form. I'm not sure it is possible. But you'll find that out quickly. A form is easier because the form has an open and close trigger by itself where you can construct and deconstruct the automation variable. But if events are fired in codeunits you can tackle that easally.

    Here are a few things to take in consideration:
    - don't clear the automation variable before raising the event!
    - C/AL local automation variable cannot receive events
    - check in "C/AL globals" if the property "WithEvents" is set to yes. If it is you should see a custom trigger added at the bottom of the codeunit.

    Maybe that'l help 8)
    In a world without Borders or Fences, who needs Windows and Gates?
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I guess you need to set the SingleInstance property as well on the codeunit.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • janpieterjanpieter Member Posts: 298
    That depends.

    ActiveX components can be (mostly are) multiple instance to so in most cases this i believe is not neccesary.
    In a world without Borders or Fences, who needs Windows and Gates?
  • elisiosousaelisiosousa Member Posts: 10
    I think that Activex's are single instance and multiple thread...
  • janpieterjanpieter Member Posts: 298
    I'm not much the theory guy but as far i know:

    An Activex DLL is multiple instance. An Activex DLL runs (or appears to run) in the same thread as the calling thread.

    An Activex EXE can be singleinstance, but i think this is only singleinstance if you create the object from the same thread. If you call the component from multiple threads i believe you get a different instance for each thread.

    :idea: :wink: 8)
    In a world without Borders or Fences, who needs Windows and Gates?
  • nelsonnelson Member Posts: 107
    Luc was refering to the SingleInstance property on Navision codeunit objects.
    Nelson Alberto
Sign In or Register to comment.