?
Solved

Getting the name of the attachments in Lotus Script

Posted on 2003-02-25
11
Medium Priority
?
1,235 Views
Last Modified: 2013-12-18
I have a richtext field in a form.  When ever the user attaches documents in this field, I have to ensure that only the attachments in the form of zip or doc should be attached.  For this purpose I have to get the name of the file attachment.  In lotus script is there any way to get the name of a file attachment?  @attachmentnames is useless in this case, since I need to know the name of the attachments attached in a particular rich text field.  Any one can help in this regard?
0
Comment
Question by:sganeshkanth
[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
  • 5
  • 3
11 Comments
 
LVL 13

Expert Comment

by:CRAK
ID: 8015657
You would have to save the document first as attachments can only be read in the backend. The doc. can remain open though, sou you could avoid ending up with wrong attachments in QueryClose and QueryModeChange.

After save you can access NotesUIDocument.Document (=NotesDocument)
In the NotesDocument you could access the appropriate Richttextfield using GetFirstItem. You should have both the NotesItem and NotesRichTextItem properties and methods available there.
Check the item for EmbeddedObjects (use "HasEmbedded"). If there are any available, there could be OLE objects, attachments etc. so you'd have to check and make sure you only continue on the attachments (Obj.Type). For attachments you need the "Source" property of the embeddedobject.

Check help for details!
0
 

Author Comment

by:sganeshkanth
ID: 8015751
I have already tried this option (Please see the following piece of code)

If strOldStatus <> strCurStatus Then
  If strCurStatus="320-Waiting for baseline approval" Then
    strFlag = "SAR Approval field on the Financial tab"
    Set attachementItem=doc.GetFirstItem("SARApprovalWord")
     If Not(attachementItem Is Nothing) Then
       If Isarray(attachementItem.EmbeddedObjects) Then
     Forall o In attachementItem.EmbeddedObjects
       If ( o.Type = EMBED_ATTACHMENT ) Then
         If Instr(1, o.name, ".doc", 5) > 0 Then
          strFlag = ""
         Elseif Instr(1, o.name, ".zip", 5) > 0 Then
          strFlag = ""
         End If
            End If
      End Forall
     End If
   End If
End If

In this code, while debugging I came to know that o.name is returning some hexadecimal value if the name of the attachment contains any special charecters (like hyphen, underscore etc.).  It returns the name of the attachment correctly when the name of the attachment doesn't contain special charecters.  Also, this is the case when I use o.Source instead of o.name in the above code.
0
 

Author Comment

by:sganeshkanth
ID: 8015827
I have already tried this option (Please see the following piece of code)

If strOldStatus <> strCurStatus Then
  If strCurStatus="320-Waiting for baseline approval" Then
    strFlag = "SAR Approval field on the Financial tab"
    Set attachementItem=doc.GetFirstItem("SARApprovalWord")
     If Not(attachementItem Is Nothing) Then
       If Isarray(attachementItem.EmbeddedObjects) Then
     Forall o In attachementItem.EmbeddedObjects
       If ( o.Type = EMBED_ATTACHMENT ) Then
         If Instr(1, o.name, ".doc", 5) > 0 Then
          strFlag = ""
         Elseif Instr(1, o.name, ".zip", 5) > 0 Then
          strFlag = ""
         End If
            End If
      End Forall
     End If
   End If
End If

In this code, while debugging I came to know that o.name is returning some hexadecimal value if the name of the attachment contains any special charecters (like hyphen, underscore etc.).  It returns the name of the attachment correctly when the name of the attachment doesn't contain special charecters.  Also, this is the case when I use o.Source instead of o.name in the above code.
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 63

Expert Comment

by:Zvonko
ID: 8015942
This is the normal behavior whit generated names when you have two attachments with same name or special characters in source file name.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 8015974
I tried your code with only minor modifications:

Sub Click(Source As Button)
     Dim WS As New NotesUIWorkspace
     Dim UIDoc As NotesUIDocument
     Dim doc As NotesDocument
     
     Set UIDoc = Ws.CurrentDocument
     Call UIdoc.Save
     Set doc = UIDoc.Document
     
     ' removed conditions
     strFlag = "SAR Approval field on the Financial tab"
     Set attachementItem=doc.GetFirstItem("RTattach") ' different fieldname
     If Not(attachementItem Is Nothing) Then
          If Isarray(attachementItem.EmbeddedObjects) Then
               Forall o In attachementItem.EmbeddedObjects
                    If ( o.Type = EMBED_ATTACHMENT ) Then
                         Messagebox o.name & " - " & o.source ' removed conditions
                    End If
               End Forall
          End If
     End If
End Sub

It showed all attachmentnames as expected, including "a_b~c'd-e.txt", for both the source as the name property.

Is there any involvement of a web-client? In URL's e.g. spaced may get translated to "%20" = ascii 32 in hex.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 8015980
Zvo's suggestion returns filenames starting with "ATT" for the duplicate names.
0
 

Author Comment

by:sganeshkanth
ID: 8016079
Yes CRAK.  I am for o.name it is showing a name starting with "ATT" as Zvo said.  In that document I found that another richtext field has the same attachment.  How to overcome this situation.
0
 
LVL 13

Accepted Solution

by:
CRAK earned 200 total points
ID: 8017758
Well, the ATT-attachments appear not to have any extension (like doc or zip), so they don't meet your validation is notes gets its way.
The least you could do is give a warning about "duplicate attachment names" to the user.

Alternatively, you could skip them since they have duplicate names. If the others are ok, so would they be!

I think the situation depends on your additional intends / demands. I can't advice you on that!
0
 
LVL 13

Expert Comment

by:CRAK
ID: 8018859
Be careful deleting the ATT-attachment: it could be a newer version one of the other attachments!
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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