Navision Automation library v1.0

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2011-03-23 in Download section
Navision Automation library v1.0
Navision Automation library to use IObjectDesigner, IAppBase, IHyperLink monikers (from RunningObjectTable).

This library can be used to import/export objects, access data and open hyperlinks from any application (JavaScript/PowerShell/Python/VBScript/VB etc)

http://www.mibuso.com/dlinfo.asp?FileID=1193

Discuss this download here.

Comments

  • meeuwmeeuw Member Posts: 9
    To use this library first use:
    regsvr32 navisionautomation.dll

    Then you can use (i.e.) Power Shell to access navision:

    C:\> $na = new-object -com NavisionAutomation.1

    C:\> $rot = $na.RunningObjectTable

    C:\> $rot.names
    lists all instances

    C:\> $objectdesigner = $rot.ObjectDesigner(1)
    get objectdesigner instance (index 1 in runningobjecttable)

    C:\> $strm = $objectdesigner.ReadObject(1,18)
    get stream for table (=1) object (=18)

    C:\> $strm.seek(0,0)
    Start at position 0

    C:\> $strm.Read($strm.Size())
    Read Object
  • bvbeekbvbeek Member Posts: 32
    Nice Automation Dick!

    Below an example in AutoItScript to export table 18 in text format:

    --
    Local $NAV_Instance = 1 ;In my case (see array $NAMES for all available innstances)
    Local $lInt_ObjectType = 1 ;1=Table, 2=Form, 3=Report, 4=Dataport, 5=Codeunit, 6=XMLPort, 7=MenuSuitem 8=Page
    Local $lInt_ObjectID = 18 ;Table 18 = Customer

    $NAV = ObjCreate("NavisionAutomation.1")
    $ROT = $NAV.RunningObjectTable
    $NAMES = $ROT.names
    $OD = $rot.ObjectDesigner($NAV_Instance)
    $strm = $OD.ReadObject($lInt_ObjectType,$lInt_ObjectID)
    $strm.Seek(0,0)
    $size = $strm.Size

    ConsoleWrite($strm.Read($size))
    ---
    Yours,
    Bart van Beek
    Boltrics Professionals B.V. | www.boltrics.nl
    Nekovri Dynamics | 3PL Dynamics
  • meeuwmeeuw Member Posts: 9
    This powershell script can be used to iterate over table 2000000038 and export all code objects:
    $na = new-object -com NavisionAutomation.1
    $rot = $na.RunningObjectTable
    $objectdesigner = $rot.ObjectDesigner(1)
    $enum = $rot.AppBase(1).GetTable(2000000038).EnumRecords
    while ($rec = $enum.NextRecord()) {
    	$objecttype = $rec.GetFieldValue(1)
    	$object = $rec.GetFieldValue(3)
    	if ($objecttype -eq 5) {
    		$strm = $objectdesigner.ReadObject($objecttype, $object)
    		$strm.Seek(0,0)
    		$buf = $strm.Read($strm.Size())
    		$m = [regex]::matches($buf, "^OBJECT (Codeunit) ([0-9]*) (.*)")
    		if ($m[0].Groups[1].Value -eq "Codeunit") {
    			$filename = "C"
    		}
    		$filename += $m[0].Groups[2].Value
    		$filename += $m[0].Groups[3].Value
    		$filename += ".nav"
    		Write-Output $filename
    		Write-Output $buf | Out-File $filename
    		break
    	}
    }
    
  • LyuchinLyuchin Member Posts: 23
    Hi all,

    I'm getting an error below (platform Windows 7 x64):
    PS C:\> $na = new-object -com NavisionAutomation.1
    New-Object : Retrieving the COM class factory for component with CLSID {B1099FD9-F00F-4F42-8C16-C5
    e to the following error: 80040154.
    At line:1 char:17
    + $na = new-object <<<< -com NavisionAutomation.1
    + CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

    I've registered dll by executing regsvr32 d:\Projects\UpgradeTimeEstimation\navisionautomation.dll. So what am I doing wrong? Please assist me.
  • LyuchinLyuchin Member Posts: 23
    Solved. The dll should be build with target platform x86 :)
Sign In or Register to comment.