问题描述
所有人,这里有一个有趣的地方,可能只是我做错了,所以可以使用您的帮助。
我有功能...
function updateStatusNStage(status, stage) {
var dfdStatusUpdate = new $.Deferred(function() {
var reqList = modCommon.SharePointContext.get_web().get_lists().getByTitle('RequestDetails'),
uListItem = reqList.getItemById(ProjectContext.ItemID);
uListItem.set_item('Stage', stage);
uListItem.set_item('Status', status);
uListItem.update();
modCommon.SharePointContext.executeQueryAsync(onQuerySNSWriteSucceeded, onQuerySNSWriteFailed);
function onQuerySNSWriteSucceeded() {
modCommon.ShowMessage('Stage updated on ' + ProjectContext.ItemID + ' to status of ' + status + ' and stage of ' + stage);
}
function onQuerySNSWriteFailed(sender, args) {
alert('Stage Update Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
});
return dfdStatusUpdate.promise();
}
当我执行以下命令时,只有第一个有效。 在我看来,第一次电话会议已经兑现了诺言,那么我该怎么做?
function stageCompleteCheck(stage) {
var dfd = gheaSPDataAccess.GetDataFromSP("ReviewerAssignment",
"<View><Query><Where><And><Eq><FieldRef Name='RequestID' /><Value Type='Number'>" +
modARBRequest.ProjectContext.ItemID + "</Value></Eq><Eq><FieldRef Name='Stage' /><Value Type='Text'>" +
stage + "</Value></Eq></And></Where></Query><ViewFields><FieldRef Name='ID' /><FieldRef Name='RequestID' />" +
"<FieldRef Name='ReviewerEmail' /><FieldRef Name='CategoryID' /><FieldRef Name='Comments' /><FieldRef Name='Result' />" +
"<FieldRef Name='Modified' /><FieldRef Name='Stage' /></ViewFields></View>");
dfd.done(function (reviewsSubmitted) {
if (modCommon.IsRealValue(reviewsSubmitted)) {
var reviewersAssignedCnt = $.grep(reviewsSubmitted, function (obj) {
return obj.Result !== 'NoResult';
});
if (reviewsSubmitted.length >= reviewersAssignedCnt.length) {
// all reviews are in
if (stage === 'Voting') {
var dfdStatusUpdate = modARBRequest.UpdateStatusNStage('Open', 'Voting Completed'); // finalize voting
dfdStatusUpdate.done(function() {
var updStatus = modARBRequest.UpdateStatusNStage('Open', 'Review Initiated'); // initiate review
updStatus.done(function () {
alert('hit second update');
});
});
}
if (stage === 'Review') {
var dfdStatusUpdate = modARBRequest.UpdateStatusNStage('Open', 'Review Completed'); // finalize review
dfdStatusUpdate.done(function() {
modARBRequest.UpdateStatusNStage('Closed', 'Final'); // finalize request ?? Do you want a pre-final status to review the decision?
});
}
}
}
});
无效的部分如下...
if (stage === 'Voting') {
var dfdStatusUpdate = modARBRequest.UpdateStatusNStage('Open', 'Voting Completed'); // finalize voting
dfdStatusUpdate.done(function() {
var updStatus = modARBRequest.UpdateStatusNStage('Open', 'Review Initiated'); // initiate review
updStatus.done(function () {
alert('hit second update');
});
});
}
感谢您可以为此提供的任何帮助。
1楼
发现我没有在UpdateStatusNStage函数中添加.resolve()。 DOH!
function updateStatusNStage(status, stage) {
var dfdStatusUpdate = new $.Deferred(function() {
var reqList = modCommon.SharePointContext.get_web().get_lists().getByTitle('RequestDetails'),
uListItem = reqList.getItemById(ProjectContext.ItemID);
uListItem.set_item('Stage', stage);
uListItem.set_item('Status', status);
uListItem.update();
modCommon.SharePointContext.executeQueryAsync(onQuerySNSWriteSucceeded, onQuerySNSWriteFailed);
function onQuerySNSWriteSucceeded() {
modCommon.ShowMessage('Stage updated on ' + ProjectContext.ItemID + ' to status of ' + status + ' and stage of ' + stage);
dfdStatusUpdate.resolve();
}
function onQuerySNSWriteFailed(sender, args) {
alert('Stage Update Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
dfdStatusUpdate.reject();
}
});
return dfdStatusUpdate.promise();
}