module.exports = function(Self) { require('../methods/ticketTracking/filter')(Self); Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'}); Self.observe('before save', function(ctx, next) { let token = ctx.options.accessToken; let userId = token && token.userId; Self.app.models.Worker.findOne({where: {userFk: userId}}, (err, user) => { if (err) return next(err); ctx.instance.workerFk = user.id; next(); }); }); };