Save Datasource & Fire querySave/postSave events

/***
 * Save Datasource & fire querySave/postSave events
 *
 * @author Sven Hasselbach
 ***/

var dsName = "document1.DATASOURCE"; // change this to the name of the datasource you want to save
var app = facesContext.getApplication();
var ds = app.getVariableResolver().resolveVariable(facesContext, dsName);
ds.save( facesContext, true );





If you are saving a datasource via document1.save(), the querySave / postSave-events will not be executed.
To fix this, you have to use the save() method of com.ibm.xsp.model.domino.DominoDocumentData instead.

The variable dsName contains the name of your datasource followed by ".DATASOURCE". To use it f.e. with current document, you have to change to "currentDocument.DATASOURCE".

More details can be found here:
http://stackoverflow.com/questions/9735648/save-method-on-datasource-does-not-fire-querysave-postsave-events

JavaScript (Server)
Sven Hasselbach
April 17, 2012 9:13 AM
Rating
168

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



2 comment(s)Login first to comment...
Bill Fox
(at 22:09 on 22.09.2014)
Does this trigger the field validation as well?
Fero Kossuth
(at 04:06 on 18.07.2012)
Related to: http://stackoverflow.com/questions/9735648/save-method-on-datasource-does-not-fire-querysave-postsave-events