【发布时间】:2016-09-19 04:42:19
【问题描述】:
router.post("/application_action", function(req,res){
var Employee = req.body.Employee;
var conn = new jsforce.Connection({
oauth2 : salesforce_credential.oauth2
});
var username = salesforce_credential.username;
var password = salesforce_credential.password;
conn.login(username, password, function(err, userInfo, next) {
if (err) { return console.error(err); res.json(false);}
// I want this conn.query to execute first and then conn.sobject
conn.query("SELECT id FROM SFDC_Employee__c WHERE Auth0_Id__c = '" + req.user.id + "'" , function(err, result) {
if (err) { return console.error(err); }
Employee["Id"] = result.records[0].Id;
});
//I want this to execute after the execution of above query i.e. conn.query
conn.sobject("SFDC_Emp__c").update(Employee, function(err, ret) {
if (err || !ret.success) { return console.error(err, ret);}
console.log('Updated Successfully : ' + ret.id);
});
});
我在上面提供了我的代码。我需要在conn.query 中修改Employee 并在conn.sobject 中使用它。我需要确保我的第一个查询在第二个之前执行,因为我从第一个获得价值并在第二个中使用。如果您知道如何完成此操作,请告诉我。
【问题讨论】:
-
请正确缩进您的代码,以便我们阅读。
-
好的。我想有人做到了。我希望你现在可以阅读。 @jfriend00
-
您的代码显示的是路由处理程序,而不是中间件。中间件在哪里?
-
缩进已经修好了,下次请自己修。
标签: node.js express asynchronous npm salesforce