Solved

Set a field in another form.

Posted on 2004-04-19
17
209 Views
Last Modified: 2013-12-18
I have a form that when I click the button done, I should be able to update the parent which is 3 forms up. Form1(Parent),
Form2(child),Form3(child) and Form4(child). When I click done on Form4 I need to update a field in Form1 that will inform me that Form4 has been created (Y,N). THanks
0
Comment
Question by:cyle
  • 9
  • 6
  • 2
17 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10862923
Do you have the parent document id traversing through this chain.. If so you are all set

Use this function

@SetDocField( ParentUNID ; fieldName ; newValue )

~Hemanth
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10862932
Or you have to use script which finds parent iteratively and then updates it ?? Need Code ??
0
 

Author Comment

by:cyle
ID: 10862952
I might need it, but let me try your first suggestion first.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:cyle
ID: 10862981
Nope, I will be needing that lotus script, I already have this code in the same button:
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim composed As String
Set uidoc = workspace.CurrentDocument
uidoc.EditMode = True
composed = uidoc.FieldGetText( "flagdone" )
  If composed = "N" Then
    If uidoc.EditMode Then
      Call uidoc.FieldSetText("flagdone","Y")
      Call uidoc.Save
      Call uidoc.Close
    End If      
End If

And I do have the parentID in all the other forms.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10863088
Hi cyle,

Set uidoc = workspace.CurrentDocument
uidoc.EditMode = True



CONST form4flagField = "form4created"
Dim workDoc as notesDocument, parentID as string, parent as notesDocument, db as notesDatabase, parentCounter as integer
Set workDoc = uiDoc.Document
Set db = workDoc.parentDatabase
For i = 1 to 3
   parentID = workDoc.parentDocumentUNID
   set workDoc = db.getDcumentByUNID(parentID)
Next
if workDoc.getItemValue(form4flagField)(0) <> "Y" Then
    workDoc.replaceItemvalue form4flagField , "Y"
    workDoc.save false, true
End if

composed = uidoc.FieldGetText( "flagdone" )
  If composed = "N" Then
    If uidoc.EditMode Then
      Call uidoc.FieldSetText("flagdone","Y")
      Call uidoc.Save
      Call uidoc.Close
    End If    
End If


Cheers!
0
 

Author Comment

by:cyle
ID: 10863394
Sorry, but what is the "form4created"? Is it the default value of the flag field?
0
 

Author Comment

by:cyle
ID: 10868891

For i = 1 to 3
   parentID = workDoc.parentDocumentUNID
   set workDoc = db.getDocumentByUNID(parentID) ----- I debugged it and this part is giving me an "Invalid Universal ID"
Next
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10868975
If parentID is available.. my formula would have worked for you..

Here you have to iterate thru the parent docs.. Let me see if I can post you the code ..
0
 

Author Comment

by:cyle
ID: 10869026
I only have a document number (created using sequential code) which is generated when I save each form. Each form inherits each forms' document number. All forms are responses to Form1.
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 300 total points
ID: 10869249
Use this function to get the top parent of the response

Function GetTopParent As NotesDocument
      Dim s As New NotesSession
      Dim doc As NotesDocument
      Dim parent As NotesDocument
      Set db = s.CurrentDatabase
      Set doc = s.DocumentContext
      Do
            parentUnid$ = doc.ParentDocumentUNID
            If parentUnid$ <> "" Then Set doc = db.GetDocumentByUNID(parentUnid$)
      Loop Until parentUnid$ = ""
      Set GetTopParent = doc
End Function


Usage

Set parentDoc = GetTopParent
if not parentDoc is nothing
parentdoc.Form4Created = "Y"
parentdoc.save true, false
end if
0
 

Author Comment

by:cyle
ID: 10870283
Sigh! Sorry its getting too long, I hope increasing the points will help with all the help you're giving me.
I added this code in Form 4
Function GetTopParent As NotesDocument
 Dim s As New NotesSession
 Dim doc As NotesDocument
 Dim parent As NotesDocument
 Set db = s.CurrentDatabase
 Set doc = s.DocumentContext
   Do
     parentUnid$ = doc.ParentDocumentUNID  ------ this part gives me "Object variable not set"
       If parentUnid$ <> "" Then
        Set doc = db.GetDocumentByUNID(parentUnid$)
       End If
   Loop Until parentUnid$ = ""
   Set GetTopParent = doc
End Function

And this is being called by a "Done" button with this code in Form4

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim composed As String
Set parentDoc = GetTopParent  -------- calls the function      
Set uidoc = workspace.CurrentDocument
uidoc.EditMode = True
composed = uidoc.FieldGetText( "flagdone" )
If composed = "N" Then
  If uidoc.EditMode Then
    Call uidoc.FieldSetText("flagdone","Y")
    Call uidoc.Save
    Call uidoc.Close
  End If      
End If
End Function
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 200 total points
ID: 10870474
cyle,
>  Set doc = s.DocumentContext

This won't necessarily work when you have a doc open using a form, and want to press abutton on the form.  Use:

Dim workspace as new notesUiWorkspace
Dim uidoc as notesUiDocument
Set uiDoc = workspace.currentDOcument
Dim doc as notesDocument
Set doc = uiDoc.document
0
 

Author Comment

by:cyle
ID: 10870529
Both goes to same form4?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10878528
It will work qwal..It is always inmemory doc..

Cyle.. Grade B is little discouraging :-(
0
 

Author Comment

by:cyle
ID: 10878560
Honestly, it was an A but my mouse is not working with me today he is faster, I cannot catch up.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10878571
Better take control of your mice or else you will be in trouble :-)
0
 

Author Comment

by:cyle
ID: 10878598
Anyway, thank you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question