mibuso.com

Microsoft Business Solutions online community
It is currently Thu May 23, 2013 4:04 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Navision Automation library v1.0
PostPosted: Tue Jul 13, 2010 11:31 am 
Offline
Site Admin

Joined: Sun Nov 07, 1999 8:01 am
Posts: 1900
Location: Wilrijk, Belgium
Country: Belgium (be)
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.


Top
 Profile  
 
 Post subject: Re: Navision Automation library v1.0
PostPosted: Tue Jul 13, 2010 12:17 pm 
Offline

Joined: Wed Feb 18, 2009 10:11 pm
Posts: 8
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


Top
 Profile E-mail  
 
 Post subject: Re: Navision Automation library v1.0
PostPosted: Fri Jul 16, 2010 10:04 am 
Offline

Joined: Thu Jan 03, 2008 3:26 pm
Posts: 25
Country: Netherlands (nl)
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))
---


Top
 Profile  
 
 Post subject: Re: Navision Automation library v1.0
PostPosted: Wed Jul 21, 2010 9:20 am 
Offline

Joined: Wed Feb 18, 2009 10:11 pm
Posts: 8
This powershell script can be used to iterate over table 2000000038 and export all code objects:

Code: Select all
$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
   }
}


Top
 Profile E-mail  
 
 Post subject: Re: Navision Automation library v1.0
PostPosted: Wed Mar 23, 2011 1:40 am 
Offline

Joined: Tue Mar 23, 2010 1:04 pm
Posts: 18
Country: Czech Republic (cz)
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.


Top
 Profile E-mail  
 
 Post subject: Re: Navision Automation library v1.0
PostPosted: Wed Mar 23, 2011 10:27 am 
Offline

Joined: Tue Mar 23, 2010 1:04 pm
Posts: 18
Country: Czech Republic (cz)
Solved. The dll should be build with target platform x86 :)


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: