LotusScript - update a field on a document, with a field from another doc in the same view

Discussion in 'Lotus Notes Programming' started by Chris O'Neill, Feb 20, 2004.

  1. I am trying to search a view and select a field from one particular
    document and take the value of that field and update another document
    in the same view. The documents are unrelated other than the fact
    that they are in the same category of a categorized view.
    I have been able to retrieve the one document's field value(by
    assigning it " Set CompanyYTDLossItem =
    doc.GetItemValue("zhrYTDLoss")"), but I can't seem to find the write
    LotusScript to update the other document fields with the value of
    CompanyYTDLossItem.
    The AppenditemValue method creates a new item with the same name. I
    tried ReplaceItemValue method, but I can't assign it the value(of
    CompanyYTDLossItem) that I am retrieving from the other document.
    Is there a get value method from one document
    and a setvalue method to another document that I can use?
    thanks
    Chris

    Dim session As NotesSession
    Set session = New NotesSession
    Dim db As NotesDatabase
    Set db = session.CurrentDatabase
    Dim view As NotesView
    Set view = db.GetView("2004 Planning")
    Dim doc As NotesDocument
    Set doc = view.GetFirstDocument
    Dim CompanyYtdLoss As Integer
    Dim ComanyYTDLossItem As NotesItem
    Do
    CompanyDoc = doc.zhrSETLoss(0)
    If CompanyDoc = "John Gillen Co." Then
    CompanyYTDLoss = doc.zhrYTDLoss(0)
    Set CompanyYTDLossItem = doc.GetItemValue("zhrYTDLoss")

    'This code is a 'Type Mismatch' :
    CompanyYTDLossItem = CompanyYTDLoss
    Messagebox "Test" & "John Gillen's YTD Loss is : " &
    CompanyYTDLoss, MB_ICONINFORMATION, "What is the total number?"
    End If
    Set doc = view.GetNextDocument(doc)
    Loop Until doc Is Nothing

    Messagebox "Test" & "John Gillen's YTD Loss is : " & CompanyYTDLoss,
    MB_ICONINFORMATION, "What is the total number?"
     
    Chris O'Neill, Feb 20, 2004
    #1
    1. Advertisements

  2. Chris O'Neill

    Urs Meli Guest

    Hi

    What about the CopyItem Method?


     
    Urs Meli, Feb 21, 2004
    #2
    1. Advertisements

  3. Hi,
    Thanks for help.
    The CopyItem method, will copy a notes item to the 'same' document; I
    am trying to copy the field to a different document(but still in the
    same view).
    Your suggestion got me started on "CopyItemToDocument" method however
    I am still running into issues with this one.
    Below is my code. I am able to asign the notes item the value of the
    field I want to copy(on the first loop of the doc's in the view),
    however when I try and assign that copied value to another document
    found by using another loop of the doc's in the view, I am getting an
    object variable not set.
    Any Idea's?
    Again thanks for you help

    Set doc = view.GetFirstDocument
    Do
    CompanyDoc = doc.zhrSETLoss(0)
    If CompanyDoc = "Gillen Company" Then
    CompanyYTDLoss = doc.zhrYTDLoss(0)

    Set CompanyYTDLossItem = doc.GetFirstItem("zhrYTDLoss")
    '--Call CompanyYTDLossItem.CopyItemToDocument(doc, "CompanyYTDLoss")

    Messagebox "Ineger Field is : " & CompanyYTDLoss,
    MB_ICONINFORMATION, "What is the number?"
    End If
    Set doc = view.GetNextDocument(doc)
    Loop Until doc Is Nothing

    Set doc = view.GetFirstDocument
    Do
    CompanyDoc1 = doc.zhrSET(0)
    If CompanyDoc1 = "Gillen Company" Then
    Call CompanyYTDLossItem.CopyItemToDocument(doc, "CompanyYTDLoss")->
    (debugger get's an error on the line above)
    End If
    Set doc = view.GetNextDocument(doc)
    Loop Until doc Is Nothing
     
    Chris O'Neill, Feb 21, 2004
    #3
  4. Chris O'Neill

    Jon Leirdal Guest


    What about using a lotus-script that uses the DialogBox function (Lookup
    the view and return your field from a selected document, and set this
    value to the field in the first document)

    Good luck

    Jon
     
    Jon Leirdal, Feb 23, 2004
    #4
  5. Hi Chris,

    what about using doc.save(...) before you get the next document in your
    loop? Without saving any modification to the document will be lost. To
    assign the value use
    TargetDoc.targetFieldName = SourceDoc.SourceFieldName(0)

    --
    *****************************************
    Cheers!

    Stefan

    (remove the No spaM from address, don't remove the @)

    http://home.arcor.de/stefan.deutzmann
    *****************************************
     
    Stefan Deutzmann, Feb 23, 2004
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.