Delete document in XPages

I have just started developing in XPages.I have a view on an XPage.

I would like to add a column to a view that allows users to delete the document. In traditional Domino development, I would have added a pass-thru HTML column to my view which called an agent via a URL (passing the document id as a parameter). The agent would then delete the document.

Can this be done more efficiently in XPages (ie. can I remove the call to the agent and just perform the delete through XPages server-side script?).

Subject: Yes it can

Hi,

I’m assuming you want to do this using a standard view control.

  • select the view control, all properties

  • enter the value “viewRow” in the property data → var

  • add a column to the view control

  • select the new column and goto data

  • select the option “computed value”

  • enter this formula: “<a href="">delete”

  • goto the Event tab of the new column and enter this formula for the onClick event:

var id = viewRow.getUniversalID();

var doc:NotesDocument = database.getDocumentByUNID(id);

viewRow.remove(true);

That’s it! Now if you open the XPage a new column is added with a link in it containing the text “delete”. If you click the link, the server side code is executed and the page is refreshed.

Good luck,

Mark

Subject: Need little bit modification in code

You are code is fine friend. But I think it require one minor changes.

instead viewRow.remove(true) I think it should be doc.remove(true)

Thanks

Vikas K Sinha