| 
| 
| 
| #204976 - 2012-04-26 08:05 AM  trouble converting VB script using COM to kix |  
| Sam_B   Getting the hang of it
 
 Registered:  2005-10-25
 Posts: 68
 Loc:  Bern, Switzerland
 | 
Hi Kix experts, 
 I'm currently developing a script that automates the user setup for a Lotus Notes Client. Works quite well for about 80 % of the work to be done, but now I'm stuck
 
 I was quite able to convert below VB code to kix but I'm stuck now at line
 
 strName = domDocument.GetItemValue("FullName")(0)
 
 I assume that GetItemValue method returns a two dimensional array?
 
 I tried $strName = $domDocument.GetItemVale["FullName",0] but this doesn't work, a empty string is returned...
 
 I know that Notes is not that popular and using KIX together with Notes either, but it's worth a try to post my problem here, you never know...
 
 Greetings from Switzerland!
 
 Samuel
 
 
 
 
 
Dim domSession As New Domino.NotesSession   
Dim domDatabase As New Domino.NotesDatabase
Dim domDocument As NotesDocument
Dim domViewEntry As NotesViewEntry
Dim domView As NotesView
Dim domViewNav As NotesViewNavigator
Dim strName As String
domSession.Initialize
Set domDatabase = domSession.GetDatabase("", _
"names.nsf")  
Set domView = domDatabase.GetView("Contacts")
' This view contains the list of names
Set domViewNav = domView.CreateViewNav
Set domViewEntry = domViewNav.GetFirstDocument()
Set domDocument = domViewEntry.Document
strName = domDocument.GetItemValue("FullName")(0)
MsgBox strName
Set domViewEntry = Nothing
Set domViewNav = Nothing
Set domView = Nothing
Set domDocument = Nothing
Set domDatabase = Nothing
Set domSession = Nothing
 Edited by Mart (2012-04-26 09:48 AM)
 Edit Reason: Please use code tags when posting code.
 |  
| Top |  |  |  |  
| 
| 
| #204980 - 2012-04-26 02:52 PM  Re: trouble converting VB script using COM to kix
[Re:  Lonkero] |  
| Arend_   MM club member
 
       
   Registered:  2005-01-17
 Posts: 1896
 Loc:  Hilversum, The Netherlands
 | 
Try this:
 
$strName = $domDocument.GetItemValue("Fullname")
? $strName[0]
 |  
| Top |  |  |  |  
| 
| 
| #204990 - 2012-04-26 08:14 PM  Re: trouble converting VB script using COM to kix
[Re:  Lonkero] |  
| Sam_B   Getting the hang of it
 
 Registered:  2005-10-25
 Posts: 68
 Loc:  Bern, Switzerland
 | 
Sorry guys not to include the scriptlet at the beginning, I had it not available this morning. See below in bold where the script crashes.
 
; ------------------------------------------------------------------------------------
; Change Mail File Location from "on Server" to "on local" for all location documents
; ------------------------------------------------------------------------------------
Function SetMailFileLocationToLocal($oNotesSession)
  Dim $oBook            ; Adress book object
  Dim $ret              ; Return value of function call
  Dim $LocationView     ; Location view
  Dim $LocationDocument ; Location document
  Dim $valueArray
  ;
  $SetMailFileLocationToLocal = 0
  ; -------------------------------------------------------------------------------------
  ; For The Current User in The Current Session, Get All The NABs
  ; -------------------------------------------------------------------------------------
  For Each $oBook in $oNotesSession.addressbooks
    ; -----------------------------------------------------------------------------------
    ; Check If The Current NAB is Private or Public
    ; If The NAB Is Private, Than It Should Be Your Personal NAB
    ; -----------------------------------------------------------------------------
    ? "Name of adressbook: " $oBook.filename
    If $oBook.isprivateaddressbook 
      ; ---------------------------------------------------------------------------------
      ; Verify if The NAB is Open, If Not, Open it
      ; ---------------------------------------------------------------------------------
      If Not ($oBook.isopen)
        $ret = $oBook.open("", $oBook.filename) ;Now Get All The Docs in The Location View
      EndIf
      $LocationView = $obook.getview("Locations")
      $LocationDocument = $LocationView.getfirstdocument 
      While @ERROR = 0
        $valueArray = $LocationDocument.GetItemValue("MailType")
        ? "Mailtype: " $ValueArray[0]
here I get
[b]ERROR : Error in expression: this type of array not supported in expressions.!
Script: I:\Scripting\SDSDeploy\CH\CH_SetupClient\Work\test3.KIX
Line  : 62[/b]
        $LocationDocument = $LocationView.getnextdocument($LocationDocument)
      Loop
    EndIf
  Next
EndFunction
; ----------------------------------------------------------------------------------------
; Start Notes Session
; ----------------------------------------------------------------------------------------
Function StartNotesSession()
  ;Die Session starten
  $StartNotesSession = CreateObject("Notes.NotesSession")
  If @ERROR <> 0
    $ret = MessageBox("Error starting Notes, unable to continue", "Problem with Notes configuration", 48)
    Exit 1
  EndIf
EndFunction
; =======================================================================================
; M A I N
; =======================================================================================
$PreviousState = SetOption("Explicit", "on")
Break on
Dim $Ret
Dim $MailServer
Dim $MailFileName
Dim $CSCDircatFileName
Dim $oNotesSession
Global $GloIniFile               ; INI file that controlls the parameters
;
$GloIniFile         = @SCRIPTDIR + "\NotesSetup.ini"
$Mailserver         = "<Name of Mailserver goes here>"
$MailFileName       = "<Path to mailfile goes here>"
; --------------------------------------------------------------------------------------
; read name of Notes directory to replicate
; ------------------------------------------------------------------------------------
$CSCDirCatFileName = ReadProfileString($GloIniFile, "Setup", "NotesDirectory")
If @ERROR <> 0
  $ret = MessageBox("Error reading value for NotesDirectory from " + $GloIniFile + ", unable to continue", "Problem with Notes configuration", 48)
  Exit
EndIf
; --------------------------------------------------------------------------------------
; Try to start Lotus Notes
; --------------------------------------------------------------------------
$oNotesSession = StartNotesSession()
$ret = SetMailFileLocationToLocal($oNotesSession)
;=========================================================================================
 
 I've also found the documentation for GetItemValue, the method returns an array with (I suppose) one element of string, but I'm unable to grab it...
 
 Thanks again for your help and support!!!
 
 
 GetItemValue method
 Example
 
 Given the name of an item, returns the value of that item in a document.
 
 Defined in
 
 NotesDocument
 
 Syntax
 
 valueArray = notesDocument.GetItemValue( itemName$ )
 
 Parameters
 
 itemName$
 
 
 String. The name of an item.
 
 
 Return value
 
 value
 
 
 The value or values contained in the specified name. The data type of the value depends on the data type of the item.
 Notes item type	Value return type
 Rich text	Array of strings. The text in the item, rendered into plain text
 Text or text list (includes Names, Authors, and Readers item types)	Array of strings
 Number or number list	Array of doubles
 Date-time or range of date-time values	Array of variants of type Date
 When GetItemValue returns an array, each element in the array corresponds to a value in the item. If the item contains a single value, the array has just one element.
 
 
 
 
 
 
 
 
 Edited by Mart (2012-04-26 09:59 PM)
 Edit Reason: Please use code tags when posting code.
 |  
| Top |  |  |  |  
| 
| 
| #204996 - 2012-04-27 05:01 PM  Re: trouble converting VB script using COM to kix
[Re:  Lonkero] |  
| Sam_B   Getting the hang of it
 
 Registered:  2005-10-25
 Posts: 68
 Loc:  Bern, Switzerland
 | 
Result of Vartype($Valuearry) is.... String[] Will do further tests on monday and let you know
 |  
| Top |  |  |  |  
| 
| 
| #204999 - 2012-04-28 08:28 AM  Re: trouble converting VB script using COM to kix
[Re:  Lonkero] |  
| Sam_B   Getting the hang of it
 
 Registered:  2005-10-25
 Posts: 68
 Loc:  Bern, Switzerland
 | 
Thanks to you all, I've found the solution for my problem in the meantime. Allens hint with the .value pushed me in the right direction. I found a a post of a user with the same problem:
 http://www-10.lotus.com/ldd/nd6forum.nsf/0/d2aaeebd3c340f7f852572730069702c?OpenDocument
 
 and the solution:
 
 "Hi there,
 
 i had the same problem and i was very near to kill somebody...
 But, in the last second, i found the solution:
 
 The GetItemValue returns an array which seems not to be compatible with vbscript! Try this instead:
 
 yourdoc.GetFirstItem("itemname").Text
 
 sure, multivalue fields are not very funny, because the values are joined with ; to one string, but you will get some values back...
 
 For me, its all i want :)"
 
 GetFirstItem("itemname").Text works perfectly for me as well, thanks a lot to all of you taking care of my problem, this site is THE BEST source for posting such kind of problems, no doubt about it!
 |  
| Top |  |  |  |  
 Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
 
 | 
| 
 
| 0 registered
and 456 anonymous users online. 
 | 
 |  |