?
Solved

Losing text and links in computed RT fields

Posted on 2005-03-17
17
Medium Priority
?
310 Views
Last Modified: 2013-12-18
Greetings.

I have a database in which users submit assignments to a department. Each assignment will be one of about a dozen actions that the department is supposed to accomplish, hopefully within an hour. Some things take longer. When the recipients complete the assignment, they mark the document complete. The submit time and the complete time are used to determine how long it took to perform the task.

They eventually decided that they wanted finer resolution on reports from this database, such as being able to select a submitted-date range, or other limiting criteria (such as the product line for which the action should be taken). So I developed a form with fields for how many of each action were completed in less than an hour, one to two hours, more than two hours, or still open, with plenty of hide criteria for lines with zeros, and have a PostOpen script that (if it's a new document) queries the user for selection criteria, sorts through the database for the matching records, and "counts" them into the appropriate fields for each document's specified action.

This has worked well for a year or so, but they decided then that the summary wasn't enough, and when there were documents that got counted into a category they wanted to be able to see more details about those documents.

So I put a collection of collapsed sections into the document (one for each action), with a series of rich text fields in each section (one each for less than one hour, one to two hours, more than two hours, still open). Now, as the script counts each document, it should be putting a link to that document and some descriptive text in the appropriate rich-text field. The sections are computed text saying that the links will be available after the document is closed and reopened, as I know that back-end updates to rich-text fields won't show up directly. The script also saves the (back-end) document at the end of the report generation process. There are no editable fields on the report form, so there is only a Close button in the UI. It closes without problem because of the Save in the PostOpen.

The problem is, when I generate a new report, close it, and reopen it, the only link that appears in the document is to the last document processed in the script. All other doc links and supporting text are gone. I've checked field contents in the document properties to verify that it's not just bad hide-when conditions.

An example of the report might look like this with the Details section closed (for the Check-Out action):

There were 2 Check-Out requests
    1 took more than two hours
    1 remains open
|> Details...

When I open the Details section, I get nothing.

The fields are:
There {CheckOutWW$} {CheckOutCount#} Check-Out request{CheckOutS$}
    {CheckOutOne#} took less than one hour
    {CheckOutTwo#} took between one and two hours
    {CheckOutMore#} took more than two hours
    {CheckOutOpen#} remain{CheckOutOpenS$} open
 V  Details...
    {CheckOutOneLinks - RT}
    {CheckOutTwoLinks - RT}
    {CheckOutMoreLinks - RT}
    {CheckOutOpenLinks - RT}

Of course, there are hide-when formulas so when CheckOutOne = 0 that line and the links line will both be blank. Note also that $, # and - RT are indications of the field types and not part of the field names.

CheckOutWW becomes "was" or "were" depending on the size of CheckOutCount. CheckOutS and CheckOutOpenS just properly pluralize those words.

Anyway, the code for this part looks like this:

==== BEGIN CODE ====
      Set doc = dc.GetFirstDocument      ' dc holds the documents selected for the report
      Do While Not (doc Is Nothing)
            prefix(0) = ""
            For intCount = 1 To ACTIONCOUNT
                  If doc.Action(0) = action(intCount) Then
                        prefix(0) = prefix(intCount)
                        intCount = ACTIONCOUNT + 1
                  End If
            Next
            If prefix(0) >< "" Then
                  Set item = thisDoc.GetFirstItem(prefix(0) & "Count")
                  item.Values = item.Values(0) + 1
                  If doc.Done(0) = "1" Then
                        Set dateMade = New NotesDateTime(doc.Date(0))
                        Set dateComp = New NotesDateTime(doc.DateComp(0))
                        age = dateComp.TimeDifference(dateMade)
                        If age < 3600 Then
                              Set item = thisDoc.GetFirstItem(prefix(0) & "One")
                        Elseif age <= 7200 Then
                              Set item = thisDoc.GetFirstItem(prefix(0) & "Two")
                        Else
                              Set item = thisDoc.GetFirstItem(prefix(0) & "More")
                        End If
                  Else
                        Set item = thisDoc.GetFirstItem(prefix(0) & "Open")
                  End If
                  item.Values = item.Values(0) + 1
                  Set rtItem = thisDoc.GetFirstItem(item.Name & "Links")
                  Call rtItem.AppendDocLink(doc, "Document Link")
                  Call rtItem.AppendText(":  " & doc.Product(0) & " / " & doc.Release(0) & " / ")
                  Call rtItem.AppendText("Sub: " & doc.SubmittedBy(0) & " / Comp: " & doc.CompletedBy(0))
                  Call rtItem.AddNewLine(1)
                  ' Call thisDoc.Save(True, False)
            End If
            Set doc = dc.GetNextDocument(doc)
      Loop
===== END PASTE =====
The prefix and action arrays hold lists of the actions the users can select and the field prefixes to which they map. In this example, prefix(0) would end up with "CheckOut" in it.

When I step through the code in debug mode, it's going through and appearing, anyway, to be adding the links and text to the rich-text fields. But when I open the document later, all those fields are empty. Note that I've tried saving thisDoc (the back-end document, taken from Source.Document) after each document is processed into the report, but that didn't help at all. (Actually, I ended up with no links when I did that.)

I've considered that it may be an issue with the rich-text fields not being well-enough established in the back-end document, so I've tried doing a fairly early save of the Source uiDocument. I've tried setting thisDoc from the Source.Document, and I've tried then getting the thisDoc.UniversalID into a string and resetting thisDoc from the db.GetDocByUniersalID to dissociate it from the uiDoc, the saving of which may be overwriting the back-end doc.

Any ideas what I need to do here? This seems like it should be easy!

Thanks.

-- b.r.t.
0
Comment
Question by:BarryTice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
17 Comments
 
LVL 7

Author Comment

by:BarryTice
ID: 13570357
All those fields are computed and self-referential, by the way.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13573857
Hi Barry,

>                Set rtItem = thisDoc.GetFirstItem(item.Name & "Links")

Try moving this line outside the loop. The rtitem won't change, will it, since thisDoc isn't changed?

I could make some more remarks as to your code, but overall I see no problems with it.

Cheers!
   Sjef
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13575867
Sjef --

The RT item does change, because there are four rich-text fields for each action available. One rich-text field contains links to all the documents that took less than one hour, one has links to all the docs that took 1-2 hours, etc.

So, just as the previous if-else construct selects the proper item to increment, the rtItem can't be selected until after the proper item has been determined (though only one rtItem will be selected per doc processed).

In the end, only the last rich-text item to pass through the rtItem variable ends up with anything in it.

If I trace through with the debugger, I can verify that on each loop rtItem has the proper field and at least appears to be receiving the text properly. But even if I perform the save every time an rtItem is updated, I still end up with empty rich-text fields.

As for other remarks, I would welcome them.

"Those whose sole object is truth can have no apprehensions from the severest scrutiny."
– Charles Babbage

Thanks.

-- b.r.t.

By the way, this is all in a 5.08 client, though some end users may have different versions (5.0.10 or some variation of R6). There are no web-based users of this db.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Author Comment

by:BarryTice
ID: 13575892
Each doc that's processed will have one action selected for it. (In the fields given in the example, Check-Out is the action.) From there, this script selects the appropriate item to increment, based on the time it took to complete the doc (or if it's still open). It should (and does) then select the corresponding rtItem to put the link into. But somewhere all the rtItem contents are being lost (or overwritten) before the doc is reopened.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1800 total points
ID: 13576115
Ahem... Reading too fast, making mistakes, just seeking the truth. Never liked Ada...

Apply brute force approach: create four RT-items, get all four and decide later which item you need for the update. For the rest, AFAICT, there's nothing wrong with the script.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13576215
Better, Sjef, but there are four RT items for each of the actions that could be in use.

Consider that block of sample fields I put in the original post, the fields for the Check-Out action. There are corresponding fields for each of the other possible actions, too. That's just one sample segment of what the final report looks like. So, just as there is:

There {CheckOutWW$} {CheckOutCount#} Check-Out request{CheckOutS$}
    {CheckOutOne#} took less than one hour
    {CheckOutTwo#} took between one and two hours
    {CheckOutMore#} took more than two hours
    {CheckOutOpen#} remain{CheckOutOpenS$} open
 V  Details...
    {CheckOutOneLinks - RT}
    {CheckOutTwoLinks - RT}
    {CheckOutMoreLinks - RT}
    {CheckOutOpenLinks - RT}

there is also:
There {PromoteWW$} {PromoteCount#} Check-Out request{PromoteS$}
    {PromoteOne#} took less than one hour
    {PromoteTwo#} took between one and two hours
    {PromoteMore#} took more than two hours
    {PromoteOpen#} remain{PromoteOpenS$} open
 V  Details...
    {PromoteOneLinks - RT}
    {PromoteTwoLinks - RT}
    {PromoteMoreLinks - RT}
    {PromoteOpenLinks - RT}

and:
There {MediaWW$} {MediaCount#} Check-Out request{MediaS$}
    {MediaOne#} took less than one hour
    {MediaTwo#} took between one and two hours
    {MediaMore#} took more than two hours
    {MediaOpen#} remain{MediaOpenS$} open
 V  Details...
    {MediaOneLinks - RT}
    {MediaTwoLinks - RT}
    {MediaMoreLinks - RT}
    {MediaOpenLinks - RT}

and about a dozen more. At that rate, I've got some 60 rtItems I'd have to keep track of, with a BIG ugly if-then-else block to indicate which rtItem I'd be putting the link into. Or, I guess I could figure out which of the rtItems I should be using and loop through an array of them, selecting the one that has the proper name...

The document being processed (doc, not thisDoc) has one action assigned. That action, combined, with how long it took to complete the action, determine which field gets incremented and which field should get a link appended.

I may have to go with that big array. I hadn't considered that until now. It's a kludge, but kludges work, too.

-- b.r.t.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13576384
:'(

A meta-question: why use that many rtitems in a report? In my mind, a report is a one-shot document, produced only once and inspected many times. WOuld a different approach be acceptable, i.e. just a text-version? Or a nice PDF-file?
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13576465
I used to have just the text (without the Details collapsed section, which means without any rich-text) but they said that didn't make it easy enough for them to look into the assignments that had caused trouble. So the rtItems are there to put hold links to each of the documents referenced. This way, they can open the section and it will have some text details about the link, either for viewing or printing, and they can click the link to view the document that took 3 hours to process, to read any comments it may contain about why it took so long. The key there is the links.

For the sake of simplicity, I didn't mention in the above that before the code goes into this loop it goes through the rtItems and appends rtStyles and some label text for each field. That's all getting lost, too, so I figured it wasn't critical to the success of this question -- if we found a way to not lose the links, we probably wouldn't lose the style and labels, either.

Also, as mentioned in the first post, the PostOpen code contains a check of whether the Source is a new document, and only goes through all this trouble for new documents. So the code is really only run once.

All questions (meta and otherwise) welcomed, and any changes to approach will be considered.

Thanks!

-- b.r.t.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13576509
Or try a
    Delete rtitem
before setting it to a new object? Hoping it will clear memory a little?
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13576525
But, if the dc has, say, 40 documents in it, and two of those documents end up going into the CheckOutOneLinks rtItem, if I Delete rtItem before I append the second link, I'm guaranteed to lose the first.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13576534
Perhaps
set rtItem = Nothing
might work...
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13576705
Another meta-level up: it seems a waste of energy to spend 3 hours of computation on generating a report that only a few people will look at. Cannot you split it up? One overall report, and if they want to know more, they open a <project> or whatever it is, push a button and a detailed report will be generated? What do they really want to know? That's a question they probably cannot answer...

What I'd do? I'd buy a reporting tool that generates PDF, and I'd whack everything into that PDF-file. Then let them skip sections when they're not interested. Let's pray they won't get the awful idea of printing the report. BAD idea, but not your problem. If they do, then generate several smaller reports.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13576775
Heh. Buy a reporting tool.

I'm afraid you're under the misconception that I have a budget...

My complete budget for this issue (or any of my Notes issues, for that matter) is however many EE points I've accrued.

Actually, the report generates pretty quickly -- a matter of a few minutes for me, even with several hundred records in the mix, and I work remotely. For people in the office it's not a time killer at all.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13577888
Barry,

> and they can click the link to view the document that took 3 hours to process

I must have misunderstood this line, although a few minutes of processing is still considerable, even remote (assuming you run a local replica). Anyway, that's not the problem, is it?

There must be A budget, for time (thus money) is being spent on generating the reports. But I don't want to step into a very tricky minefield, so I'll refrain from further comments into that direction.

Now your problem. What if you execute just a test in a test database? Generate a document, with only a few rt-fields, and create links in those fields. Does that work?
Then another option: would it be allowed to have one main report document with 60 response documents? Much easier to generate, easily displayed in a view, come to think of it: in an embedded view with Show single category. Just a suggestion...

By the way, I got very strange results in a database that had too many fieldnames in its field-index. In R6 there is a setting Allow more fields in database, maybe setting that one will solve it. You're in EE much longer than I am, so you must have tried lots of other things already, like Fixup and Compact and the like.

Sjef
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 200 total points
ID: 13577892
Don't do it in PostOpen.  Use an agent. Have it create an in-memory document, open a diaglogbox to get the criteria.  When teh user closes the dialog box, it can work merrily on gathering the results (summary and docLinks) and placing them in the same in-memory doucment.  When done, save it with a full form name to display, and open that.  You should be good.

Note: if you want to show the quey options in the result document, put that in a subform.  The subform can display directly in a dialog box, and can be included in the results form, too.  Don't put the result fields on the subform.

Another option:
Build a folder to diaply the reuslts, with categories having totals to give the summary.  Then, just move your results into the folder.  No document for results at all.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13579343
Qwaletee --

If I were going to start from scratch at this point, I would absolutely do it with an agent. But I had enough of the rest of the script working in its previous state that I don't feel like making that conversion.

Sjef --

Sadly I'm not working on a local replica. But even connecting to a server several states away (over a DSL Internet connection) a report over 300 documents is about five minutes. It's not too bad.

I've implemented the rtItem array, and that seems to have done the trick. I'd still like to know why this has been a problem, though. Finding work-arounds without identifying the real problem doesn't suit my tastes very well, I'm afraid.

In any case, thanks for the help.

-- b.r.t.
0
 
LVL 7

Author Comment

by:BarryTice
ID: 13579366
Sjef --

I see now where the three hours comes in.

Remember that this is a report of how long it took the department to process requests for various actions. Some end user says, "I need you to perform a check-out." The department in question performs the check-out and then markes the request complete. The request document tracks how long it took the person to perform the check-out (from the time the request was submitted until the time it was marked complete).

The reports I'm generating sort through all these documents and summarize how many check-out documents took less than an hour, how many took between one and two hours, and how many took more than two hours. The rich-text fields in the report contain doclinks to the original request documents, so if there was a check-out request that took three hours to complete, the person generating the report (a process that takes a minute or two in the office) can follow the link in the report to view the check-out request that took three hours to complete, to see if there were some conditions about that particular request that justify the lengthy delay.

Clear as mud?

-- b.r.t.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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