[solved] Autoform - attach session value before insert not working?



I’m using aldeed:autoform for inserts and updates.
Each document to be inserted needs:

  • The current userId (works)

  • A generated "productCountId"
    This gets generated when the user routes to the form and is then stored in a Session.

To attach these values to the inserted document I use AutoForm.addHooks().


I can’t get the Session value in the “before insert” hook.

Currently my code looks like this:

var addProductHooks = {
  before: {
    insert: function(doc) {
      doc.productCountId = Session.get('productCountId');
      doc.owner = Meteor.userId();
      return doc;
  onSuccess: function() {

AutoForm.addHooks('product_from_add', addProductHooks);

Why cant i get the Session like this?
Many thanks for your help.


Okay, I found my error:
I simply forgot to add the productCountId to my Schema. :-/