Solved

Set a field in another form.

Posted on 2004-04-19
17
206 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now