Solved

Evaluate contents of a RTF

Posted on 2002-03-20
40
417 Views
Last Modified: 2013-12-18
I would like to evaluate to content of a Rich Text Field, and based on the evaluation of the field set the value of another field.

In my scenario I want to require the user to attach a document to a form.  I have already built a "user friendly" button to allow them to attach the document and set a status flag.  However, I want to ensure that they actually attach the document by evaluating the content of the field (RTF).  If the value is null I want to populate a status field to reference status A; if a document is present in the RTF I want to populate the status field to status B.  

I currently have it set-up so that when they use the "attach button" the status us automatically changed to status B.  The problem that I have is there is no validation that there is actually an attachment present.  (A few users have figured out that you can depress the "attach button" and then cancel the action instead of attaching the document.  I have the field and some status flags populated when they execute the "attach button".)

Ideas on how to validate that there is actually something in the RTF?
0
Comment
Question by:mvm835
  • 15
  • 15
  • 10
40 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6883685
There is exactly no such function which can search the empty of RT item. RT Item is realized only when the document is saved. So use this script to track if the user clicked cancel or selected a file..

     Dim ws As New NotesUIWorkspace
     Dim note As NotesDocument
     Set note = ws.CurrentDocument.Document
     
     stringArray =ws.SaveFileDialog( False, "Select the attachment to be saved to the document !", "All Files|*" )
     If Not Isempty(stringArray) Then
          note.AttachFile = stringArray(0)          
     ' Set the flags          
     End If    

Basically, the script intercepts the user to query the file for attaching, then the complete path is stored in AttachFile field in the document.


Write this script in an agent and trigger the agent from the macro using toolsrunmacro, then check the attachfile field for null and process the flags accordingly.

~Hemanth
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6883687
Small correction in the script,

    Dim ws As New NotesUIWorkspace
    Dim note As NotesDocument
    Set note = ws.CurrentDocument.Document
    note.AttachFile = ""      'Reset the file
    stringArray =ws.SaveFileDialog( False, "Select the attachment to be saved to the document !", "All
Files|*" )
    If Not Isempty(stringArray) Then
         note.AttachFile = stringArray(0)          
    ' Set the flags          
    End If    

0
 
LVL 10

Expert Comment

by:zvonko
ID: 6883928
Hello mvm,

the problem with Hemanthas code is, when user enters a nonsense string for the SaveFileDialog() you get this invalid file name stored into note.AttachFile item and have to check later on your own for valid attachments :-)

My proposal goes one step further. I would check whether there is an Attachment present on QuerySave event.
Here the code to do this check:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
  Dim doc As NotesDocument
  Set doc = Source.Document
  doc.StatusB = False
  Forall item In doc.Items
    If ( item.Type = ATTACHMENT ) Then
      Print "FileName: " & item.Values(0)
      doc.StatusB = True
    End If
  End Forall
  If Not (doc.StatusB(0) = True) Then
    Msgbox "No Attachments found"
    Continue = False
  End If
End Sub

Cheers,
zvonko


0
 

Author Comment

by:mvm835
ID: 6884046
Question on the script... on lines 8-12(script as follows).  I'm missing or misunderstanding the instructions.

thanks


Sub Exiting(Source As Field)
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim ws As New NotesUIWorkspace
     Dim note As NotesDocument
     Set note = ws.CurrentDocument.Document
     note.Appraisal_Report = ""      
     StringArray =ws.SaveFileDialog( False, "Select the attachment to be saved to the document !", "All      Files|*" )
     If Not Isempty(stringArray) Then
          note.AttachFile = stringArray(0)          
          doc.Status = "6 - Appraisal Completed"
          doc.Statusflag5 = "1"        
     End If    
     Call uidoc.RefreshHideFormulas
End Sub
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6884140
there are three errors:

 If Not Isempty(stringArray) Then
         note.AttachFile = stringArray(0)          
-->       doc.Status = "6 - Appraisal Completed"
-->       doc.Statusflag5 = "1"        
    End If    
-->  Call uidoc.RefreshHideFormulas

You have assigned the BackEnd NotesDocument:
Set note = ws.CurrentDocument.Document
to "note", never assigned to "doc"
The "uidoc" also never assigned.

And as mentioned before: ws.SaveFileDialog() does not save anything :-)
You´have not to select one of the files; you can type in: John Doe (it is a valid file name :-)

Why do you not give a try to my proposal?


0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6884399
MVM835,

I assumed that you had somekind of macro which is attaching the file and setting flags. It can be done in script too.

Here is the complete code and method to attach file into the richtext field (Here I used 'RT' as the name, replace it accordingly)

' THIS GOES INTO A BUTTON
=========================
Sub Click(Source As Button)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim note As NotesDocument
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     
     stringArray =ws.SaveFileDialog( False, "Select the attachment to be saved to the document !", "All Files|*" )
     If Not Isempty(stringArray) Then
          exists = Dir$( stringArray(0) )
          If exists = "" Then
               Msgbox "File (" & stringArray(0) & ") does not exist" , 16, "Error finding file"
               'note.Status = "5 - Appraisal Incomplete"
               'note.Statusflag5 = "0"        

          Else
               'Set the fields
               note.AttachFile = stringArray(0)              
               note.Status = "6 - Appraisal Completed"
               note.Statusflag5 = "1"        
          End If
          Call uidoc.GotoField( "RT" )           ' Rich Text field where the attachment should be placed
          Call uidoc.Refresh
     End If    
     
End Sub
============================

'THIS GOES IN EVENT POSTRECALC
==============================
@If( AttachFile = ""; @Return(0); @Do(@Command( [EditInsertFileAttachment] ; AttachFile ; 1 ); @SetField("AttachFile"; "")) )


Zvonko, Don't push hard on the asker to accept your solution. I appreciate you pointing the mistake in my code. But don't make it a habit of always pointing mistakes and think that you are always right, it makes you a silly person. I appreciate if you don't make this question lengthy with unecessary comments. If you want to guide the user, then take this question. Even I don't have time to compete/argue with you. I always adored the knowledge that you had, but never critcized !


~Hemanth
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6884819
Sorry Heman, next mistake :-)

If the user pushes two times your button and select tow times a valid file, then he get two attachments into the RT field.
All right so far, BUT, when he deletes these two attachments by hand, he is able to save the document without attachments but with flag fields wrong set. Is this not an error? Is this comment too long for you <|:-)

Hello mvm, when do you test my code :-)







 
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6885818
Yes that is an exposure and I never said that the solution is foolproof, it is just an alternate to trap cancel button in attachment dialog.

MVM, there is always an vulnerability as discussed above. So what do you want to do. In my solution the flags change and attachments are made. But still while saving you have to validate that the relation of Richtext to flag match is intact. So you have to make a check before you can save the document. Only the save can realize the Richtext item. So what do you want to do ???

0
 
LVL 10

Expert Comment

by:zvonko
ID: 6885854


only to recall: my upper code DOES exactly this check <|:-)



0
 

Author Comment

by:mvm835
ID: 6885858
Hemanth:

Thanks for the quick response.  Entered the changes as indicated and runs with no errors, however, in testing I'm still able to circumvent the process.  The user manually selects which file(s) to attach (1-2) per request.  The script needs to be attached to the RTF field (if possible); having it on the attach button will necessitate changing 7-10 other fields and actions.  The script does not appear to catch instances where there is nothing in the RTF (when on the RTF field).  Ideas?



Zvonko:

I like the concept of QuerySave to validate.  Tried the code attached to the RTF file and users were still able to circumvent the process.  I'm a little confused by your "StatusB" reference (which may be why I had problems).  The field is STATUS and B is one of 11 variables available (each variable being a different status).  Ideas?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6886531
OK let us give the user full access of attachment via normal File..Attach menu

And here is the script which validates if there is any attachment in the RichText field,

============================
Function ValidateRT(Field As String) As Variant
     'Validation to find if there is atleast one attachment in this document
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDOcument
     Dim note As NotesDocument
     Dim rt As NotesRichTextItem
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     AttachmentFound = False
     Call uidoc.Refresh(True)
     Set rt = note.GetFirstItem( Field )
     ' Check for attachments in the richtext item
     emobjs = rt.EmbeddedObjects
     If Isarray(emobjs) Then
          Forall emobj In emobjs
               If (emobj.Type=EMBED_ATTACHMENT) Then
                    AttachmentFound = True
               End If
          End Forall
     End If    
' Set the flags
     If AttachmentFound Then
          note.Status = "6 - Appraisal Completed"
          note.Statusflag5 = "1"
     Else
          'note.Status = "5 - Appraisal InComplete"
          'note.Statusflag5 = "0"      
     End If
     Print "Attacment Found: " & AttachmentFound
     ValidateRT = AttachmentFound
End Function
============================


Call this in Exiting of any RichText field and as well as Querysave. Like this,

ValidateRT( "RT" )    'RT is the name of the richtext field to be validated.

And you should be all set.

0
 
LVL 10

Expert Comment

by:zvonko
ID: 6886816
Hello mvm,

use this:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
  Dim doc As NotesDocument
  Set doc = Source.Document
  doc.AttachmentsFound = 0
  Forall item In doc.Items
    If ( item.Type = ATTACHMENT ) Then
      Print "FileName: " & item.Values(0)
      doc.AttachmentsFound = doc.AttachmentsFound(0) + 1
    End If
  End Forall
  If Not (doc.AttachmentsFound(0) > 0) Then
    Msgbox "No Attachments found"
    Continue = False
  End If
End Sub

This QuerySave does not save the document when not at least one attachment is found.
Based on this AttachmentFound document item, you can calculate your Status field as you like :-)

What do you mean with "able to circumvent the process"?
Of course are user allowed to cancel document processing without save. But with my code set in QuerySave they are not able to save the document before at least one file is attached.

Cheers,
zvonko



0
 

Author Comment

by:mvm835
ID: 6889874
Hemanth:

Thanks for the QUICK RESPONSE and your efforts; they are appreciated.

I think that I've entered everyting correctly (I'm not receiving any script errors.)  Everyting sounds and looks logical, however, when I populate all of the fields and exit or save without a RT Attachment in the specified field nothing happens.  When the user manually selects the document they wish to attach the Status field is set to "6 - Appraisal Completed".  In reading the code that you wrote I thought that if they exited without attaching a document (by hitting cancel) the status would be changed to "5 - Management Review".  If I complete this operation the status remains at "6 - Appraisal Completed".

Am I missing something or did I incorrectly input some of the script?
 
Following is what I have attached to the RT field (Appraisal_Report):


ValidateAppraisal_Report contains the following:

Function ValidateAppraisal_Report (Field As String) As Variant
    'Validation to find if there is atleast one attachment in this document
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDOcument
     Dim note As NotesDocument
     Dim rt As NotesRichTextItem
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     AttachmentFound = False
     Call uidoc.Refresh(True)
     Set rt = note.GetFirstItem( Field )
    ' Check for attachments in the richtext item
     emobjs = rt.EmbeddedObjects
     If Isarray(emobjs) Then
          Forall emobj In emobjs
               If (emobj.Type=EMBED_ATTACHMENT) Then
                    AttachmentFound = True
               End If
          End Forall
     End If    
' Set the flags
     If AttachmentFound Then
          note.Status = "6 - Appraisal Completed"
          note.Statusflag5 = "1"
     Else
          note.Status = "5 - Management_Review"
          note.Statusflag5 = "0"      
     End If
     Print "Attacment Found: " & AttachmentFound
     ValidateRT = AttachmentFound
End Function

On Exit Contains the following:

Sub Exiting(Source As Field)
     ValidateAppraisal_Report ( "RT" )
End Sub

Sub Exiting(Source As Field)
     ValidateAppraisal_Report ( "RT" )
End SubSub Exiting(Source As Field)
     ValidateAppraisal_Report ( "RT" )
End SubSub Exiting(Source As Field)
     ValidateAppraisal_Report ( "RT" )
End SubSub Querysave(Source As Notesuidocument, Continue As Variant)
     Dim doc As NotesDocument
     Set doc = Source.Document
     doc.AttachmentsFound = 0
     Forall item In doc.Items
          If ( item.Type = ATTACHMENT ) Then
               Print "FileName: " & item.Values(0)
               doc.AttachmentsFound = doc.AttachmentsFound(0) + 1
          End If
     End Forall
     If Not (doc.AttachmentsFound(0) > 0) Then
          Msgbox "No Attachments found"
          Continue = False
     End If
End SubSub Querysave(Source As Notesuidocument, Continue As Variant)
     Dim doc As NotesDocument
     Set doc = Source.Document
     doc.AttachmentsFound = 0
     Forall item In doc.Items
          If ( item.Type = ATTACHMENT ) Then
               Print "FileName: " & item.Values(0)
               doc.AttachmentsFound = doc.AttachmentsFound(0) + 1
          End If
     End Forall
     If Not (doc.AttachmentsFound(0) > 0) Then
          Msgbox "No Attachments found"
          Continue = False
     End If
End Sub
0
 

Author Comment

by:mvm835
ID: 6889879
Sorry, got carried away with paste function...

On Exit Contains the following:

Sub Exiting(Source As Field)
    ValidateAppraisal_Report ( "RT" )
End Sub
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6890095
Dear MVM,

put this code into QuerySave and tell me when wrong status occure by Cancel/Escape:

Sub Querysave(Source As Notesuidocument, Continue As Variant)
  If Not Source.InPreviewPane Then
    Dim doc As NotesDocument  
    Set doc = Source.Document
    If doc.IsValid Then
      If (doc.HasEmbedded And (doc.Statusflag5(0) <> "1"))Then
        doc.Status = "6 - Appraisal Completed"
        doc.Statusflag5 = "1"
      Elseif (doc.HasEmbedded = False) Then
        doc.Status = "5 - Management_Review"
        doc.Statusflag5 = "0"    
      End If
    End If
  End If
End Sub

You have to allow the customer to discard started changes and roll back to previous state (not to save document).
The only condition is: if document has to be saved, then it has to be saved with correct status. This is done by upper short script.

That is all.



0
 
LVL 10

Expert Comment

by:zvonko
ID: 6890118
Sorry,

the correct script is this one:
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
  Call Source.Refresh
  Dim doc As NotesDocument  
  Set doc = Source.Document
  If doc.HasEmbedded Then
    doc.Status = "6 - Appraisal Completed"
    doc.Statusflag5 = "1"
  Elseif (doc.HasEmbedded = False) Then
    doc.Status = "5 - Management_Review"
    doc.Statusflag5 = "0"    
  End If
End Sub

This tripple confusing code with escape/preview/deleted document is driving me crazy.

This is my last try to convice you that this is such simple as this few lines. Otherwise I get mad :~9



0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6892114
MVM, By including Zvonko's code, you are confusing yourself.

Just put the code that I mentioned in previous comment

Either call the function directly, or

ValidateAppraisal_Report ( "RT" )

Continue = ValidateAppraisal_Report ( "RT" ) ' This will block the save if it doesn't contain attachments and reverts the status back for no attachments.

0
 

Author Comment

by:mvm835
ID: 6896304
Hemantha:

Still doesn't stop the report from being saved or change the status flag to 5 (indicating that there is no attachment).  Is there something that I'm missing?

On Exit the following script is present:

Sub Exiting(Source As Field)
     Continue = ValidateAppraisal_Report ( "RT" )
End Sub


ValidateAppraisal_Report contains the following script:

Sub Exiting(Source As Field)
     Continue = ValidateAppraisal_Report ( "RT" )
End Sub



There is no Query Save nor any other fields set to a default.
0
 

Author Comment

by:mvm835
ID: 6896311
Zvonko:

Sorry, sounds simple and easy however it doesn't work.  Did I miss something?  All other options for this field are blank.

On QuerySave the following script is present:

Sub QuerySave(Source As Notesuidocument, Continue As Variant)
     Call Source.Refresh
     Dim doc As NotesDocument  
     Set doc = Source.Document
     If doc.HasEmbedded Then
          doc.Status = "6 - Appraisal Completed"
          doc.Statusflag5 = "1"
     Elseif (doc.HasEmbedded = False) Then
          doc.Status = "5 - Management_Review"
          doc.Statusflag5 = "0"    
     End If
End Sub
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6896537
No, not that. It should be like this,

Sub Exiting(Source As Field)
    ValidateAppraisal_Report ( "RT" )
End Sub

Sub QuerySave(Source As Notesuidocument, Continue As Variant)
    Continue = ValidateAppraisal_Report ( "RT" )
End Sub

I have tested this code thoroughly and it works.

PS: Rem Zvonko's code before you do this.



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 10

Expert Comment

by:zvonko
ID: 6896555
No, you do not miss anything. This should be all you need.

The concept is following:
if something is changed, for example attachments added or removed, then user can press escape and cancel. Doing this does not affect the document integrity: if with attachments before editing, then correct State is not changed. If without attachment, then the state is correct too.
If anywhere on the form an action requests to save the document, then this QuerySave code is executed and the correct State fields are calculated.

Let us look at an example:
user open a document without attachment, embed an attachment and press CTRL-S. Doing so is the QuerySave code executed and State set to Attachment Found. After save command he does some more editing, press cancel to abandon changes and escape saving. What is the last document State on disk? This is the one with the QuerySave calculated State fields. That is all you need. You do not need to check the attachments at every field enter and exit.

So my question is: where do you get problems? What action can guide to wrong document States?


0
 

Author Comment

by:mvm835
ID: 6896693
Hemantha:

By adding the QuerySave function I now receive an informational message "OBJECT VARIABLE NOT SET" (press OK) if the user tries to exit without attaching a document. When the user attaches a document I have the status flag automatically set to "6 - Appraisal Completed". However, from the script it looks as though the status field should be changed to "5 - Management Review" if there is no attachment.  This does not happen.  

My code on the attachment button follows:

@Command([EditInsertFileAttachment]);
FIELD Routing_Date := Routing_Date;
FIELD Attachment := "1";
FIELD Status := "6 - Appraisal Completed";
@SetField("Routing_Date";@Today)

I have tried deleting the FIELD Status := "6 - Appraisal Completed" to see if this helps and it does not.


PS:  None of Zvonko's code is present on the document.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6897335
On the debugger and check where it is giving error. Also there is a small correction in your function

check last line
ValidateRT = AttachmentFound

it should be
ValidateAppraisal_Report = AttachmentFound
0
 

Author Comment

by:mvm835
ID: 6897668
The last line was changed as indicated.

When I run the ValidateAppraisal_Report script it stops on the emobjs = rt.EmbeddedObjects line.  no error messsage is given; the debugger stops on this line.  It appears that this is also the line that pops up the "OBJECT VARIABLE NOT SET" message.

Since I changed the last line of the script I still receive the "OBJECT VARIABLE NOT SET" message.  Also, when on the attachment window that allows the user to select a file if I hit cancel the window appears a second time (stacked on top of the other).  If I hit cancel a second time then the "OBJECT VARIABLE NOT SET" message appears.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6897755
Hello mvm,

my upper unintended pasted code with the checking for uidoc.InPreviewPane and uidoc.IsValid is exactly to avoid this ObjectVarNotSet errors you get now.
The error occurs because this uidoc is going through several states. If you have a preview frame open, then is the field code also executed there. Checking rt for EmbeddedtObjects property is only end of a chain because Document property returned Nothing from uidoc because of an escape/abort. For this was the doc.IsValid checking.

But this is all not necessary. If you place your code into QuerySave, then this code is never executed in Preview or Deleted objects. Only when uidoc is really saving.

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6897847
BTW, what is the version of notes that you have !
0
 

Author Comment

by:mvm835
ID: 6899490
Hi Hemantha:

I'm working in version 5.04.  I think that I have discovered the reason that I was receiving the window to attach the file twice...   The code below the ATTACH button:  
@Command([EditInsertFileAttachment]);
FIELD Routing_Date := Routing_Date;
FIELD Attachment := "1";
FIELD Status := "6 - Appraisal Completed";
@SetField("Routing_Date";@Today)

The first line was listed twice.  By removing the extra @Command([EditInsertFileAttachment]) line it appeared to fix the problem.

Maybe I'm dense...  I'm not sure that I understand your previous comment.  My objective was to have the status field (which is set to "6 - Appraisal Complete" when the user presses the ATTACH button) changed to "5 - Management Review" if there was no attachment present in the Appraisal_Report field.


I currently have the following events attached to the APPRAISAL_REPORT field.

1.  Attach button (listed above)

2.  Declarations
Dim uidoc As NotesUIDOcument
Dim note As NotesDocument
Dim rt As NotesRichTextItem

3.  Exiting
Dim uidoc As NotesUIDOcument
Dim note As NotesDocument
Dim rt As NotesRichTextItem

4.  ValidateAppraisal_Report
Function ValidateAppraisal_Report (Field As String) As Variant
    'Validation to find if there is atleast one attachment in this document
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDOcument
     Dim note As NotesDocument
     Dim rt As NotesRichTextItem
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     AttachmentFound = False
     Call uidoc.Refresh(True)
     Set rt = note.GetFirstItem( Field )
    ' Check for attachments in the richtext item
     emobjs = rt.EmbeddedObjects
     If Isarray(emobjs) Then
          Forall emobj In emobjs
               If (emobj.Type=EMBED_ATTACHMENT) Then
                    AttachmentFound = True
               End If
          End Forall
     End If    
' Set the flags
     If AttachmentFound Then
          note.Status = "6 - Appraisal Completed"
          note.Statusflag5 = "1"
     Else
          note.Status = "5 - Management_Review"
          note.Statusflag5 = "0"      
     End If
     Print "Attacment Found: " & AttachmentFound
     ValidateAppraisal_Report = AttachmentFound
End Function

5.  QuerySave
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
     Continue = ValidateAppraisal_Report ( "RT" )
End Sub


Am I missing something?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6899713
Copy the function (validateAppraisal_Report) to global...declarations section. So that the function is available to whole form. In your case the scope of the function is to field and destroyed after exiting the field.

0
 

Author Comment

by:mvm835
ID: 6899826
I pasted the ValidateAppraisal_Report to the Global section.  No change.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6900261
The attach button will not change anything, only in the exit from rt field will fire validation or if the user is in rt field and since there is no chance of firing exit event then we trap the checking in querysave. I am assuming that you are looking for the status to change just by clicking attach or cancel button. Right !
0
 

Author Comment

by:mvm835
ID: 6900405
The status changes to "6 - Appraisal Completed" when the user depresses the ATTACH button.  I was looking to have the status changed back to "5 - Management Review" if they exited the APPRAISAL_REPORT field without placing an attachment in the field (or saved the document without exiting the field).  I do use 8 other status indicators at different phases of the process, so I can't set it to automatically change to "5 - Management Review" when they save or exit the document; the ticker is that they have to have attempted to place an attachment in the field.  At the current time, when the user enters the APPRAISAL_REPORT field the status is set to "5 - Management Review".  When they click on the ATTACH button the status is changed to "6 - Appraisal Completed".  My hope was to have it changed back to "5 - Management Review" if nothing was present in the APPRAISAL_REPORT field.

Possible?
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6900461
MVM, understand finally that this is wrong approach.

You try to keep your workflow simple by observing one field at one time. But this results in conflicts with other fields.

If you have different workflow states and many workflow dependent fields you get a never ending chain (or even worser: network) of dependencies.

My proposal, and this is really the last time, is to place all your workflow decisions into QuerySave event.

Good luck,
zvonko

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6901325
Change your button code like this

@Command([EditInsertFileAttachment]);
FIELD Routing_Date := Routing_Date;
FIELD Attachment := "1";
@SetField("Routing_Date";@Today);
@PostedCommand([EditNextField]);
@PostedCommand([EditPrevField]);

Last two commands forces an exit in the richtext field and sets the focus back to richtext after the validation is all over. Not so slick, but will work.

0
 

Author Comment

by:mvm835
ID: 6902431
Made the change and now if nothing is attached in the Appraisal_Report field the status remains "5 - Management Review".  Upon save or exit when there is no attachment an informational message "OBJECT VARIABLE NOT SET".

When I actually attach a document into the Appraisal_Report field I also receive the "OBJECT VARIABLE NOT SET" message upon save or exit of the field.  Also, I thought there was a line of script to change the status to "6 - Appraisal Completed" if there was an attachment present.  This is not happening.

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6902665
Ok, did u switch the debugger on and see where the problem occurs.

Also if possible send me the db, with few documents to test and the form in context to hemanthakumark@bigfoot.com, Let me take a look .
0
 

Author Comment

by:mvm835
ID: 6902948
The debugger stops on the validate line of:

emobjs = rt.EmbeddedObjects

I've stripped down the "garbage" and set it to you.

thanks
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6903766
Send it to, hemanth@boxfrog.com
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 200 total points
ID: 6905720
Here is the problem, the function parameter "RT" is an example field name but it doesn't contain in your form.

The function accepts name of the richtext field, and function gets the handle to it based on the passed name .

So in your case the function should be called as

     ValidateAppraisal_Report ( "Appraisal_Report" )

Hope you understand the function, if you have any doubts let me know


0
 

Author Comment

by:mvm835
ID: 6905804
Works!

You were wonderful...   Thanks so much.
0
 

Author Comment

by:mvm835
ID: 6905812
Very patient, thorough and knowledgeable.  Always professional and considerate.  Hemantha did not accept "no" as an option, and dogmatically pursued a workable solution.  Top Noch!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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 article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

12 Experts available now in Live!

Get 1:1 Help Now