How can we compile objects using code from inside navision

pradkpradk Member Posts: 89
I need to compile a form from within navision using the code and not via object designer->f11.
Is it possible to do so. If yes then how ?
](*,)

Comments

  • WaldoWaldo Member Posts: 3,412
    I think the only way to do it is using keystrokes (sendkeys).

    Just search in the form how to use it:
    e.g.: http://www.mibuso.com/forum/viewtopic.php?t=598&highlight=sendkeys

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Search the forum for "SendKeys"
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • WaldoWaldo Member Posts: 3,412
    Hah, I was first, Luc \:D/

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Great minds think alike =D>
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • mximxi Member Posts: 9
    I know the thread is old, but I want to do the same stuff: Compile Objects from the code.

    I have try it with sendkeys but it only works if i don't wait till all objects compiled. And I have to know if the last Object is compiled.

    If I wait till the last Object is compiled, I am getting in an infinite loop. The Object will never be compiled because the sendkeys commands will be executed at the end and the end will not be reached because the sendkeys were not executed. ](*,)
    WSHShell.SendKeys('+{F12}');
    WSHShell.SendKeys('%A');
    WSHShell.SendKeys('%');
    WSHShell.SendKeys('B');
    WSHShell.SendKeys('A');
    WSHShell.SendKeys('{F11}');
    WSHShell.SendKeys('%J');
    CLEAR(WSHShell);
    
    ...
    
    IF Object.FINDLAST THEN BEGIN
      WHILE NOT Object.Compiled DO BEGIN
         Object.FINDLAST;
      END;
    END;
    

    I've inserted a sleep to wait a few minutes, but it doesn’t help.

    Sendkeys are always executed at the end. And I need it to do it directly.

    Has anybody an idea to fix this problem or another idea to compile the objects??
  • rhpntrhpnt Member Posts: 688
    Why would anybody want to compile an object from code!? :shock:
  • mximxi Member Posts: 9
    For example if you have imported Objects by code and you want to compile them to execute afterwards a report or something like this.
  • rhpntrhpnt Member Posts: 688
    mxi wrote:
    For example if you have imported Objects by code and you want to compile them to execute afterwards a report or something like this.

    Why would you import objects by code!? :shock:

    Never mind...
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Another example: if you use the Form Transformation Tool to create pages, with the new "Transform" button from this download: Easy One-Click Form Transformation. Then you could compile the page, immediately after it was imported automatically.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • WaldoWaldo Member Posts: 3,412
    Cool tip, Luc .. I'm gonna try that button :mrgreen: ..

    There are a few ways to compile an object. There are even a few downloads on MIbuso that can help you with that. Even CodeGenius opens up possibilities.. .
    BUT, you have to be careful with this, because you have to import the file first, and then try to compile it. IF not possible to compile, you loose your old version of the object and you're stuck with the uncompiled version of the object ... so be careful with that!

    We're building a source control tool at this moment (which will be available later this year) where we will try to expose compile functions in the most safe way as possible... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • WaldoWaldo Member Posts: 3,412
    By the way .. Sendkeys are not necessary .. just plain code!

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • mximxi Member Posts: 9
    Thanks to all for your posts. I think I have found what I’m searching for.

    Now I only have to make it working. ;-) Never used PowerShell before.
  • WaldoWaldo Member Posts: 3,412
    Can I ask .. what is it that you're trying to do?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • mximxi Member Posts: 9
    Sure you can...

    I'm trying to create an updater. Which import, compile and execute Objects.

    Following your tip to look in the download section, I found the Navision Automation libary (http://www.mibuso.com/forum/...) which I only can start with a PowerShell script.
    So I'm creating the script and start it from the code, but if I'm checking if my objects compiled the PowerShell don't execute. So it is the same Porblem as with the SendKeys.

    Did you mean another Entry in the download section? Or where is my mistake?
  • WaldoWaldo Member Posts: 3,412
    Well, do you use CodeGenius?

    If so, there is an automation that comes available: "The Ultimate Microsoft Dynamics NAV Tool". that's the one you should be using .. . (Actually .. I suppose it's codegenius, but I'm not 100% sure).

    You can connect to the client with your database name.
    then compile the object with the object type and object id as parameters.
    As a result, you get a boolean (succeeded or not)

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • reijermolenaarreijermolenaar Member Posts: 256
    This automation is part of the Object Manager.
    You can download it here.
    Reijer Molenaar
    Object Manager
  • WaldoWaldo Member Posts: 3,412
    :-)
    In my "programs and features" window, I've got "CodeGenius for Object Manager 4.1" .. confusing :mrgreen:

    I have installed both .. sorry, I didn't know ..

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • mximxi Member Posts: 9
    Thanks for your suggestions Waldo and reijermolenaar.

    As you know I've tried the Navision Automation libary (http://www.mibuso.com/forum/...).
    But it seems to me that the Navision Automation libary don't work solid or I do something wrong. I call it with a generated powershell script and sometimes it works sometimes not. :?
    Furthermore if the powershell worked all Errors appears separate in a message box and not once. Up to 100 times the same message appears.

    After that I downloaded the Object Manager. It is a very powerfull tool. But I only need to compile objects. And I don't want import so many objects in a customer database.

    So have anybody another idea for compiling objects from code?
    Perhaps it would help me, if I could see the code how the object manager compile objects. :)
  • WaldoWaldo Member Posts: 3,412
    In my understanding, you don't have to import the objects at all. just install the msi (so that your automation comes available) and use it..

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.