Has anyone migrated from the Worklist.sdk to the REST API ?
We use the Worklist.sdk in Javascipt within a form. We have upgraded from K2 4.7 to 5.2 and can no longer use the Worklist.sdk. I have looked at the K2 documentation and I can not understand how to use the REST API in my JS.
Any help or examples greatly appreciated. My existing JS code is shown below
Thanks
Kevin
We use the following JS to get a list of tasks, and then iterate through our list views, using folio value, so the rows with associated tasks go pink containing hyperlinks to the task.
< script >
var worklistProcessed = false;
function callWorklistService() {
if (worklistProcessed) {
return;
}
var environmentCode = document.domain.substr(0, 2);
var URL = "https://" + environmentCode + "-k2runtime.northumbria.ac.uk/Runtime/Runtime/Form/My+Documents/Worklist.sdk?" + Date.now();
jQuery.ajax({
type: "GET",
url: URL,
dataType: "xml",
contentType: "application/xml; charset=utf-8",
success: function(data) {
var xmlDoc;
if ($(data).find("WorklistItemCollection").length == 0) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(data.xml);
} else {
xmlDoc = data;
}
$($("table.grid-content-table").slice(0, 4).find("tr").get().reverse()).each(function() {
var submissionID = $(this).find("td:first").text().trim();
if (submissionID.indexOf("No items to display") > -1) {
return;
}
var matchingTaskURL = $(xmlDoc).find("ProcessInstanceIFolio='" + submissionID + "']").closest("WorklistItem").find("Data").text();
if (matchingTaskURL != null && matchingTaskURL != "") {
$(this).attr("onclick", "window.location.href='" + matchingTaskURL + "'; showSpinner(); if (event.stopPropagation) { event.stopPropagation(); } event.cancelBubble = true; ");
$(this).removeClass("even");
$(this).attr("style", "background-color:#ffb3b3");
$(this).find("td").attr("style", "background-color:#ffb3b3");
if ($(this).prevAll().not("(style='background-color:#ffb3b3']").length !== 0) {
$(this).insertBefore($(this).closest("table").find("tr").not(""style='background-color:#ffb3b3']").first());
}
}
});
worklistProcessed = true;
}
});
}
callWorklistService(); < /script>