Source: https://wearetechie.wordpress.com/2014/03/07/multiple-approval-for-assign-flexi-task-in-nintex-using-jqueryjavascript/comment-page-1/#comment-82
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
<script language=”javascript” type=”text/javascript” src=”/sites/jdp/Shared%20Documents/jquery.SPServices-0.7.2.min.js”></script>
<script language=”javascript” type=”text/javascript”>
function ApproveRejectTask(status) {
debugger;
var comments = $(‘#TextAreaComment’)[0].value;
var items = getQuerystring(“Items”);
var currentListGUID = getQuerystring(“ListGUID”);
debugger;
var comments = $(‘#TextAreaComment’)[0].value;
var items = getQuerystring(“Items”);
var currentListGUID = getQuerystring(“ListGUID”);
var taskItems = items.split(‘;’)
var updateString = “<Batch OnError=’Continue’>”;
for (var i = 0; i < taskItems.length – 1; i++) {
updateString += “<Method ID=’1′ Cmd=’Update’>” +
“<Field Name=’ID’>” + taskItems[i] + “</Field>” +
“<Field Name=’Decision’>” + status + “</Field>” +
“<Field Name=’ApproverComments’>” + comments + “</Field>” +
“</Method>”;
}
updateString += “</Batch>”;
var updateString = “<Batch OnError=’Continue’>”;
for (var i = 0; i < taskItems.length – 1; i++) {
updateString += “<Method ID=’1′ Cmd=’Update’>” +
“<Field Name=’ID’>” + taskItems[i] + “</Field>” +
“<Field Name=’Decision’>” + status + “</Field>” +
“<Field Name=’ApproverComments’>” + comments + “</Field>” +
“</Method>”;
}
updateString += “</Batch>”;
$().SPServices({
operation: “UpdateListItems”,
async: false,
batchCmd: “Update”,
listName: currentListGUID,
updates: updateString,
completefunc: function (xData, Status) {
operation: “UpdateListItems”,
async: false,
batchCmd: “Update”,
listName: currentListGUID,
updates: updateString,
completefunc: function (xData, Status) {
}
});
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, “”);
}
});
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, “”);
}
function getQuerystring(key, default_) {
if (default_ == null) default_ = “”;
key = key.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”);
var regex = new RegExp(“[\\?&]” + key + “=([^&#]*)”);
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}
</script>
if (default_ == null) default_ = “”;
key = key.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”);
var regex = new RegExp(“[\\?&]” + key + “=([^&#]*)”);
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}
</script>
<table width=”100%” cellpadding=”0″>
<tr>
<td>
Comments :
</td>
<tr>
<td>
Comments :
</td>
<td>
<textarea name=”TextAreaComment” id=”TextAreaComment” cols=”30″ rows=”3″></textarea>
</td>
</tr>
<tr>
<td>
</td>
<tr>
<td>
</td>
<td align=”right”>
<input name=”ApproveBTN” type=”button” value=”Approve” onclick=”javascript:ApproveRejectTask(1)”/>
<input name=”RejectBTN” type=”button” value=”Reject” onclick=”javascript:ApproveRejectTask(2)”/>
</td>
</tr>
</table>
Step 2: Edit your Task view page and add a content editor Web Part. Open the content editor WebPart and add the below script. On click of the Approve/Reject button on the List view ribbon, the below script takes the ID of all the task item selected to
<input name=”ApproveBTN” type=”button” value=”Approve” onclick=”javascript:ApproveRejectTask(1)”/>
<input name=”RejectBTN” type=”button” value=”Reject” onclick=”javascript:ApproveRejectTask(2)”/>
</td>
</tr>
</table>
Step 2: Edit your Task view page and add a content editor Web Part. Open the content editor WebPart and add the below script. On click of the Approve/Reject button on the List view ribbon, the below script takes the ID of all the task item selected to
<script language=”javascript” type=”text/javascript”>
var siteUrl;
$(document).ready(function () {
$(document).ready(function () {
siteUrl = _spPageContextInfo.siteServerRelativeUrl;
});
});
function ApproveRejectMulti() {
var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var currentListGUID = SP.ListOperation.Selection.getSelectedList();
if (selectedItems.length > 0) {
var itemIDs = “”;
for (var i in selectedItems) {
itemIDs += selectedItems[i].id + “;”;
}
var optionsForm = { url: siteUrl + “/SitePages/ApproveRejectMulti.aspx?Items=” + itemIDs + “&ListGUID=” + currentListGUID, title: “Approve/Reject Multiple FSR”, allowMaximize: false, width: 400, height: 200, showClose: true, dialogReturnValueCallback: refreshCallback };
SP.UI.ModalDialog.showModalDialog(optionsForm);
} else {
alert(“Select at least one Task to Approve/Reject”);
}
}
var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var currentListGUID = SP.ListOperation.Selection.getSelectedList();
if (selectedItems.length > 0) {
var itemIDs = “”;
for (var i in selectedItems) {
itemIDs += selectedItems[i].id + “;”;
}
var optionsForm = { url: siteUrl + “/SitePages/ApproveRejectMulti.aspx?Items=” + itemIDs + “&ListGUID=” + currentListGUID, title: “Approve/Reject Multiple FSR”, allowMaximize: false, width: 400, height: 200, showClose: true, dialogReturnValueCallback: refreshCallback };
SP.UI.ModalDialog.showModalDialog(optionsForm);
} else {
alert(“Select at least one Task to Approve/Reject”);
}
}
function refreshCallback(dialogResult, returnValue) {
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
</script>
No comments:
Post a Comment