This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Apr 25, 2016, 2:00 PM
6 Posts
topic has been resolvedResolved

Can someone help me with LS to remove attachments? Nothing is working.

  • Category: Application Development
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 8

I'm having trouble removing attachments in LS.  The files are uploaded on my xpage, and the postsave event from the xpage calls an agent to extract the files and remove them from the document.  However, none of my attempts are working, and I don't know why.  The document is definitely saved in the LS sub.  I've tried the following...

didn't work, so then I tried using this after extracting all the files...

didn't work, so then I tried using this....

didn't work, so then I tried...

didn't work, so then I tried something else I found in the forum...

no luck... I'm running out of options and spent WAY too much time on something that is supposed to be fairly straightforward.  I don't get errors with the above approaches, but when I look at the doc properties, I can see that the files are still there.

Can somebody point out the obvious that I'm missing?

 

Apr 25, 2016, 6:34 PM
13 Posts
Save document?

The Remove method of the NotesEmbeddedObject class always work for me. Do you save the NotesDocument afterwards, it is not showing that in your code sample.

Add a doc.Save() after o.Remove and see what happens.

Apr 25, 2016, 6:51 PM
6 Posts
Yes, the script saves the doc...

I added a print statement just before the save, so I know it's saving each time.  This one really has me stumped - but I'm sure I'm missing stupid.

Apr 25, 2016, 7:16 PM
82 Posts
try this ...
Dim rtitem
Set rtitem = doc.GetFirstItem( "Body" )

If ( rtitem.Type = RICHTEXT ) Then

      ForAll o In rtitem.EmbeddedObjects

              If ( o.Type = EMBED_ATTACHMENT ) Then

                      Call o.ExtractFile ( |c:\attachments\| & o.name )

                      Call o.remove

                      Call doc.save(true, false)
              End If

      End ForAll

End If
Apr 25, 2016, 8:02 PM
6 Posts
Here are my results...

My code looks now like this...

 

I had the save command further down, but added it here to see if it made any difference.  My doc properties looked like this before I ran the code

The console shows the results...

but, when I check doc properties, nothing has changed.  It shows 5 SuppAttach fields and 6 $File fields.

Apr 25, 2016, 8:31 PM
6 Posts
Files are attached with an xpage upload control

I'm not doing anything to change the attachment type.  I'm just using the upload control "out of the box".

Apr 25, 2016, 10:25 PM
326 Posts
Try

Print out filestr and see what the value is.   Also if you run the agent manually does it work?   Does the signer of the agent have the correct right?  sess.commonusername will signer of the agent

Apr 26, 2016, 12:33 PM
6 Posts
SOLVED

Thank you for all your suggestions - sometimes it just takes another set of eyes.... my script was working with two document variables and I was saving the wrong one after the attachments were removed. 

Rookie mistake, but apparently, I still need to be humbled after 15 years of development.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal