Solved

Adding Doclink to richtext field, reopen document in edit mode with double clicking restriction.

Posted on 2006-10-26
11
815 Views
Last Modified: 2013-12-18
dear Experts,

I would like to do the following.

Create a new document(b) .
Create doclink on a richtext field for document (b) on uidoc.
Close doc, open doc for doclink to appear immediately.
Set Document to edit mode.
Change field value.

My problem is : when i reopen the document after successfully creating the doclink, the system would not allow me to change to edit mode. Yes, i have scripts in POStOPEN and QUERYMODECHANGE to prevent double clicking edit. The message that prompts was the message i used to disable double clicking editing.

EditMode = uidoc.EditMode
                        
                        
                        uidoc.Close
                        
                        
                        Set rtitem5 = doc.GetFirstItem("link_0")
                        If ( rtitem5.Type = RICHTEXT ) Then
                              
                              Call rtitem5.AppendDocLink( newdoc , "Doclink" )
                              doc.Form = "f-requestform"
                              
                              Call doc.Save( False, True )
                        End If
                        
                        Set uidoc = workspace.EditDocument( EditMode , doc )
                        
                  End If
            End If
            
            Messagebox "This item has been mark as processed.", , _
            "Ittem Filled"      
            
            
            
            allowEdit = Cint(1)
            uidoc.EditMode = True
            
            Call uidoc.FieldSetText("status" , "Partial Processed")
0
Comment
Question by:Leepingtang
  • 4
  • 2
  • 2
  • +1
11 Comments
 

Expert Comment

by:LordMacBee
ID: 17817697
if you have a script preventing edit mode then you cant change to edit mode. That restriction doesnt just prevent the user the go to edit mode but also any script doing so.
0
 

Author Comment

by:Leepingtang
ID: 17817785
But i have the same script that works on a button. Is this a constrain?
0
 

Expert Comment

by:LordMacBee
ID: 17817846
I can't quite see from your code what you are trying to achieve...
firstly, the messagebox doesnt seem to be in any way connected to the edit mode and thus is called every time. there are two 'end if' statements without the initial if statement.
secondly, it's hard to guess what else is going on in the document. Can you post the QuerySave / QueryModeChange scripts as well? Or is this code from those event handlers?

Maybee if you post the whole code...
0
 

Author Comment

by:Leepingtang
ID: 17817966
Sorry LordMAcBee, the code that i have pasted is an abstract only.

let me explain myself again.

I have the following codes to stop editing by double clicking on the form. ( forces user to use the action button that enables the form to be in edit mode. )

Sub Postopen(Source As Notesuidocument)
      If source.EditMode And Not source.IsNewDoc Then
            allowEdit = True
            source.EditMode = False
            Messagebox "Please press the Edit button to edit.",64,"Edit"
      Else
            allowEdit = False
      End If
End Sub


Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
      If allowEdit Or (source.EditMode And Not allowEdit) Then
            allowEdit = False
      Else
            Messagebox "Please press the Edit button to edit.",64,"Edit"            
            continue = False
      End If
End Sub


On event of a click on a button, a new document will be created. I want to be able to create a doclink to this newly created document and make it visible right after the click. so i have to close uidoc and add the doclink on the background. Then reopen the document once again. My problem lies here. I want to re-open the document that i have closes in EDIT MODE so user can make further changes.



'doc is close here
uidoc.Close
                        
                        'add doclink from background
Set rtitem5 = doc.GetFirstItem("link_0")
                        If ( rtitem5.Type = RICHTEXT ) Then
                              
                              Call rtitem5.AppendDocLink( newdoc , "Doclink" )
                              doc.Form = "f-requestform"
                              doc.status = "Partial Processed"
                              doc.d0_status = "P"
                              Call doc.Save( False, True )
                        End If
                        
                        'reopen doc and set as uidoc
Set uidoc = workspace.EditDocument( False , doc )
                  End If
            End If
            
            Messagebox "This item has been mark as processed.", , _
            "Ittem Filled"      
             allowedit = True
                                 uidoc.Editmode = true

' My predefined message appears once the code is executed to the above line, forcing users to use the edit button for modification. I want to bypass that so that users do not have to click on the EDIT button again.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 63

Accepted Solution

by:
SysExpert earned 20 total points
ID: 17819935
DO not use the uidoc front end, you need to get the doc handle and use backend procedure to reopen it

I hope this helps !
0
 

Author Comment

by:Leepingtang
ID: 17824938
I think  i know where you are coming from, will give it a try and let you know! Gracias mucho!!
0
 

Author Comment

by:Leepingtang
ID: 17830965
sysExpert, can you provide more details?
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 17842521
OK, apparently backend classes will not work for you since they bypass the UI and you want to reopen the doc for editing.

If that is th case, then I would simly add a hidden field with a flag that tells you that you have saved and are re-opening the doc.
If the flag is set then do Not prompt.

you already have

doc.d0_status = "P"

and you can check that to bypass the Edit prompt, or use another hidden field.

Make sure the default of the field is known and that you change it as needed.

I hope this helps !


0
 
LVL 18

Expert Comment

by:marilyng
ID: 17973043
In addition to trapping the doc.d0_Status="P" on the post open, querymodechange, and postmodechange,

change the line: Set uidoc = workspace.EditDocument( False , doc )
to:  Set uidoc = workspace.EditDocument( true , doc )


I found that when trying to track these, you need to set a status based on the button being pushed.  The Notes Mail file script library does this, actioninprogress = PUSH_SAVE

So, if you roll your query events into a script library and attach some constants to all events, then you can step through using a select case actioninprogress

Some Constants:
Const  SAVECONTINUE = 21
Const  SAVECLOSE = 20
Const  CLOSENOSAVE = 99
Const  SAVEREOPEN = 50

So, when you have an action button like: Save & Close
The first thing it does is set the actioninprogress field,  this way you know which button was pressed.  You default the button to SAVECONTINUE when the document opens in edit mode.

FIELD ActioninProgress:=50;
@if(@Command([FileSave]);@SetField("ActionInProgress";20);"")

So, the first FIELD sets the actioninprogress field to your SAVEREOPEN value, and the second one changes it so the user can close when they finish a second time.

The PostOpen, QueryModeChange, PostModeChange then can use either a combined script library or individual calls to check the value of actioninprogress:

Select Case ActioninProgress
 Case SAVEREOPEN
    do this
    do that
    do this
  Case SAVECLOSE
    Do something else
    Do another thing
   case Else
     etc.
end select

Also, when going from UI to backend, it helps to destroy the uidoc,
uidoc.close
set uidoc = nothing

But if you do this, and then change the ws.editdocument(true, doc)  it should work.  


The other nice thing about the actioninprogress field is that you can use hidewhens nicely.. actioninprogress!=50

See if this helps you.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

20 Experts available now in Live!

Get 1:1 Help Now