Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSLink to Add Comment
(function () {
document.write('<style type="text/css">.btn { background: #0072C6; background-image: -webkit-linear-gradient(top, #0072C6, #2980b9); background-image: -moz-linear-gradient(top, #0072C6, #2980b9); background-image: -ms-linear-gradient(top, #0072C6, #2980b9); background-image: -o-linear-gradient(top, #0072C6, #2980b9); background-image: linear-gradient(to bottom, #0072C6, #2980b9); font-family: Arial; color: #ffffff; font-size: 12px; background: #0072C6; padding: 6px 10px 6px 10px; text-decoration: none; margin-right:10px;}<\/style>');
document.write('<script type="text/javascript" src="/sites/standardwork/SiteAssets/jquery-2.2.4.min.js"></script>');
RegisterSod('hierarchytaskslist.js', '/sites/standardwork/SiteAssets/hierarchytaskslist.js');
LoadSodByKey('hierarchytaskslist.js', null);
var statusFieldCtx = {};
statusFieldCtx.Templates = {};
statusFieldCtx.Templates.Fields = {
"Action": {
"View": ShowButton
}};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();
function ShowButton(ctx) {
var _ItemId = ctx.CurrentItem.ID;
var TitleFeedback = "Send Comment to Manager";
var TaskView = "/Lists/Staffing%20Scheduling%20Standard%20Work%20Tasks/CommentForm.aspx?ID="+_ItemId;
return "<a href='javascript:void(0)' onclick=\"openViewDialog('" + TaskView + "', '" + TitleFeedback + "')\" class='btn'>Send Comment to Manager</a><a href='javascript:void(0)' onclick=\"CloseTask('"+_ItemId+"')\" class='btn'>Close Task </a>";
}
function openViewDialog(tUrl, tTitle) {
var options = {
url: tUrl,
title: tTitle,
height:600,
width:800,
dialogReturnValueCallback: function(dialogResult)
{
SP.UI.ModalDialog.RefreshPage(dialogResult)
}
};
SP.UI.ModalDialog.showModalDialog(options);
}
function CloseTask(ItemID)
{
var url = "/_api/web/lists/GetByTitle('Staffing Scheduling Standard Work Tasks')/GetItemById("+ItemID+")";
var data = {
__metadata: { 'type': 'SP.Data.Staffing_x0020_Scheduling_x0020_Standard_x0020_Work_x0020_TasksListItem' },
PercentComplete: "1",
Status:"Completed",
};
updatelist(url,data);
};
function updatelist(URL,UpdatedData){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + URL,
type: "PATCH",
headers:
{
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose",
"X-Http-Method": "PATCH",
"If-Match":"*"
},
data: JSON.stringify(UpdatedData),
success: function (data){
console.log(data);
window.location.reload();
},
error: function (error){
alert(JSON.stringify(error));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.