Frantisek Kossuth
Frantisek Kossuth

Reputation: 3524

save() method on datasource does not fire querySave/postSave events

My save button uses SSJS with some logic. I want to save datasource, so I use

document1.save();

Script works, but querySave/postSave code is not executed.

Only workaround is to use simple action and divide button event to blocks for "execute script", "Save document (simple action)" and "execute script" (just to return "navigation" string).

Is it possible to save datasource in SSJS and fire qS/pS events?

Upvotes: 3

Views: 3491

Answers (2)

Fredrik Norling
Fredrik Norling

Reputation: 3484

Sven what is the difference between your code and currentDocument.save() is something else happening than querysave and postsave?

Upvotes: 0

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

please try this SSJS code:

var dsName = "document1.DATASOURCE";
var app = facesContext.getApplication();
var ds = app.getVariableResolver().resolveVariable(facesContext, dsName);
ds.save( facesContext, true );

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".

Hope this helps

Sven

Upvotes: 17

Related Questions