We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

Leepingtang
Leepingtang asked
on
Medium Priority
862 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")
Comment
Watch Question

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.

Author

Commented:
But i have the same script that works on a button. Is this a constrain?
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...

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2007
Commented:
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 !

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I think  i know where you are coming from, will give it a try and let you know! Gracias mucho!!

Author

Commented:
sysExpert, can you provide more details?
CERTIFIED EXPERT
Top Expert 2007

Commented:
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 !


Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.