As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Collection Hooks collection('user') forOne returning no data or error
L
Lodijones
started a topic
about 9 years ago
Have had several of these Hooks set up before to send out push notifications or emails. With this new account for a new client. My problem is the logger works for calls before the forOne call but nothing is returned error or data with the forOne call. Code below:
Hi, the problem is likely is that you are calling response.continue() before waiting for the findOne function to complete. The findOne function is asynchronous, and will call the callback function you pass to it when it is finished. However, your call to response.continue() happens outside of this callback. The reason your messages aren't being logged is that once response.continue() is called, your endpoint cannot do any more processing.
There are many resources online for learning how to use asynchronous javascript code/callbacks -- one example can be found at http://recurial.com/programming/understanding-callback-functions-in-javascript/
Lodijones
****function onPostSave(request, response, modules) {****
var logger = modules.logger;
var collectionAccess = modules.collectionAccess
, userCollection = collectionAccess.collection('user')
, utils = modules.utils
, push = modules.push
, template = '{{name}}, the {{team}} just won!'
, pushedMessageCount = 0
, email = modules.email
, userCount;
logger.info("Target email: "+ response.body.email);
logger.info("Response ID: "+ response.body._id);
logger.info("Response Owner Name: " + response.body.ownerName);
userCollection.findOne({"username":'ben@manifest.com'}, function(err, doc){
logger.info('Pushing message to ' + doc);
if((err) || (doc == null)){
logger.info('ERROR ' + err);
} else {
logger.info('DOCS ' + doc);
}
});
response.continue();
}