Solved

Save issue with Rich Text Field

Posted on 2002-06-06
11
269 Views
Last Modified: 2013-12-18
I am executing a script that creates links to "program" documnts within my database, based upon a list of "program" names.  This script is called with an action button.  When this script is executed, any unsaved text that was in a rich text field within the form is deleted.  Any clue what might be causing this?  Thanks in advance for your help!

Here is the script that I am using:

' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     'This script will create links to the programs that are in the ProgramList.
     ' If the program list is blank then no links will be created, and any existing links will be deleted.
     ' If the ProgramList is not blank, then this script will loop through the programList.  
          ' If the the program is in the All Executable Programs view, then a link to that program document will be created.
          ' If the progam is not found in the view, then no link is created, and a message is provided saying that the
          '  program was not found.
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Sub Click(Source As Button)
     Dim ws As NotesUIWorkspace
     Dim uidoc As NotesUIDocument 'current document
     Dim object As Variant
     Dim doc As NotesDocument
     Dim viewdoc As NotesDocument
     Dim ProgList As NotesItem
     Dim rtitem As NotesRichTextItem
     Dim EditMode As Integer
     
     Set ws = New NotesUIWorkspace
     Set uidoc = ws.CurrentDocument
     Set doc = uidoc.Document
     EditMode = uidoc.EditMode
     uidoc.Close
     
     Doevents
     Set ProgList = doc.GetFirstItem("ProgramList")
     If (ProgList.Text <> "") Then 'If program list is blank then links aren't provided
          Set db = doc.ParentDatabase
          Set view = db.GetView( "All Executable Programs" )
          Call view.Refresh
          Call doc.RemoveItem("ProgramLinks") 'deletes current links
          Set rtitem = doc.CreateRichTextItem("ProgramLinks")
          Forall program In doc.GetItemValue( "ProgramList" )
               Set viewdoc = view.GetDocumentByKey( program, True ) 'returns the doc in the view with the matching program Name
               If (viewdoc Is Nothing) Then  
                        'Program doesn't exist in the view , no link is created and a message is provided
                    Call rtitem.AppendText(program & " - This program is not in the list of Executable Programs. Program Name or Program Type may have changed.")
                    Call rtitem.AddNewLine( 1 )
               Else
                       'creates a link to the program document and displays the program name
                    Call rtitem.AppendDocLink( viewdoc, viewdoc.ProgramName(0) )
                    Call rtitem.AppendText(viewdoc.ProgramName(0))
                    Call rtitem.AddNewLine( 1 )
               End If
          End Forall
          doc.Form = "Job"
          Call doc.Save( False, True )
     Else
          'programList is blank, so ProgramLinks should be blanked out as well.  
          Call doc.RemoveItem("ProgramLinks")
     End If
     'reopens the original job document, with the ProgramLinks field updated
     Set uidoc = ws.EditDocument(EditMode, doc)
     If (EditMode) Then Call uidoc.GotoField( "ProgramList" )
     'setting saveOptions to "0" is done so that the user is not prompted to save this document.
     'saveOptions for the currentDocument (uidoc) will be set to "1" when it is reopened
     doc.SaveOptions = "0"
End Sub
0
Comment
Question by:sauce12
  • 4
  • 4
  • 3
11 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7059391
Your script contains this code,

Call doc.RemoveItem("ProgramLinks") 'deletes current links

which deletes the richtext item totally. So you have to create two seperate rt fields one for input and other to build links. That way you can flush out the links and recreate it.

~Hemanth
0
 

Author Comment

by:sauce12
ID: 7060162
Hemanth - Thanks for the response.

I'm not sure if I made myself clear in my explanation of the problem.  

Let me clarify - When I execute this script, I lose any unsaved data in other rich text fields within my form -    Program Links is only updated by this script, it is not editable and it is not used as input.  

If I have unsaved text in any other type of field (not rich text), it seems to be saved when this script is executed.  But, rich text fields lose any unsaved data.

Does that make sense?  Any clue what's going on?

Thanks!
0
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 150 total points
ID: 7061204
I think the cause of the problem is in the difference between the uidoc and the backend document.
I noticed that in your script you use the backend document to apply changes. Rich text fields stay in the uidoc until the document is saved, maybe there's your problem.
You close the uidoc without saving it and thus the contents of your rich text fields is lost. You should first make sure that the changes in the uidoc are saved and then run the rest of your script.

Hemanth,
do you agree?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7062370
Sauce12
Ok now I gocha. In your code before uidoc.Close, insert his code uidoc.Save

JM, Yes
0
 

Author Comment

by:sauce12
ID: 7063198
Thanks!  I inserted the changed my script as is shown below and it seems to work right now.  Is this what you guys had in mind, or do you see any problems that this might cause?    

Any clue why unsaved text that is non rich text fields was being saved properly before I added this code?  I would think that I would lose data that was saved in any field, but I only seemed to lose unsaved data in rich text fields?

Also, I would assume that I should accept jerrith's answer for this question.  But, Hemanth, I appreciate your help and would like to give you some points as well.  Can I split up the points?  

Set ws = New NotesUIWorkspace
     Set uidoc = ws.CurrentDocument
     EditMode = uidoc.EditMode  
     If (EditMode = True) Then
          Call uidoc.Save 'saves any unsaved text that was in the document before this script is executed    
     End If
     
     Set doc = uidoc.Document
     uidoc.Close
0
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.

 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7066218
The reason is that rich text is not available in your document unless it was saved, that's all.
If you want to know more about it, just look up rich text problems on the Notes Gold Release forum of Lotus Development Domain : http://www-10.lotus.com/ldd/46dom.nsf?OpenDatabase

You'll see that plenty of people have the same or similar problems when accessing rich text fields using script etc.

Regards,
JM

P.S.: Since my tip pointed out to Hemanth what line needed to be included, does this mean, the points will be split? >:-)
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7069033
Well, I will always grant the points which I deserve to JM, because he is the best buddy in EE ;-)

JM, note for you. Who knows I might be stealing your points soon ...
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7069132
Sorry, Hemanth :-)
I didn't think I deserved full credit for this one. I'll be glad to offer you some points in return (I've got plenty of question points I can spent)

JM
0
 

Author Comment

by:sauce12
ID: 7071264
Hey guys, I wanted to split the points between the 2 of you, but I didn't know how to give points other than to just accept an answer.  Can I give points without accepting an answer?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7071475
It is OK guys.

Note: Sauce, you have contact EE community support center to arrange for split.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7072052
We're just goofing, sauce, don't worry. I know Hemanth is my pal, so he won't mind...

In any case if you want to split points for a question, the easiest way is to post a zero-point question in the community support forum with a link to the question for which you want the points to be split.
In the question explain how you want the points to be split and an EE moderator will take of it for you.

Regards and thanks again,
JM
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

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…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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