01-29-2009 02:50 PM
<import resource="/Company Home/Data Dictionary/Scripts/burris-common.js">
<import resource="/Company Home/Data Dictionary/Scripts/exclusion-set.js">
function transportation_dailyTasks() {
checkExpires();
checkRetention();
checkDocumentSets();
}
///////////////////////////////////////////////////
function checkExpires() {
// records that are burris, are expireable, aren't superceded, aren't terminated
var results = search.luceneSearch("TYPE:\""+BURRIS_DOC_TYPE+"\" +ASPECT:\""+EXPIREABLE_ASPECT+"\" -ASPECT:\""+SUPERCEDED_ASPECT+"\" -ASPECT:\""+TERMINATED_ASPECT+"\"");
var expireds = findExpiredRecords(results);
sendExpiredNotifications(expireds);
}
function findExpiredRecords(results) {
var found = new Array();
// find the docs that are expired and store according to group responsible so that they get one email with all the expirations
for each(var result in results) {
// files that are sitting at the facility-level are unfiled and not approve yet, ignore them
if(result.parent.parent.name == "Transportation") continue;
var properties = result.properties;
var expirationDate = properties[EXPIRATION_DATE];
var now = new Date();
var groupEntry = found[result.properties[GROUP_RESPONSIBLE]];
if(!groupEntry) {
groupEntry = new Array();
groupEntry["group"] = result.properties[GROUP_RESPONSIBLE];
found[result.properties[GROUP_RESPONSIBLE]] = groupEntry;
}
var entry = new Array();
entry["file"] = result.name;
var difference = getDayDifference(expirationDate, now);
if(difference <= 0) {
result.properties[EXPIRED] = true;
result.save();
entry["isExpired"] = true;
groupEntry.push(entry);
} else if(difference <= 30) {
entry["isExpired"] = false;
groupEntry.push(entry);
}
}
return found;
}
function sendExpiredNotifications(results) {
for each(var group in results) {
// the only reason a file won't have a group is if it hasn't been approved yet
if(group["group"] && !group["group"].match(/_x0020_/)) {
var users = people.getMembers(people.getGroup(group["group"]));
for each(var p in users) {
if (!p.properties.email || p.properties.email == " ") {
continue;
}
var mail = actions.create("mail");
mail.parameters.to = p.properties.email;
mail.parameters.from = "Burris Alfresco <noreply@burrislogistics.com>";
mail.parameters.subject = "Results from Alfresco Expiration Check";
mail.parameters.text = "Hello " + p.properties.firstName + ",\r\n\r\n";
mail.parameters.text += "This is an automated email, the result of an ";
mail.parameters.text += "Alfresco Expiring Record check. The results are ";
mail.parameters.text += "listed below.\r\n\r\n";
var hasFiles = false;
for each(var item in group) {
if (!item["file"]) continue;
hasFiles = true;
mail.parameters.text += " * " + item["file"] + ": ";
mail.parameters.text += item["isExpired"] ? "expired" : "expiring in less than 30 days";
mail.parameters.text += "\r\n";
}
mail.parameters.text += "\r\n";
mail.parameters.text += "Please login to Alfresco (" + ALFRESCO_URL + ") ";
mail.parameters.text += "to update these documents.\r\n\r\n";
mail.parameters.text += "Thank you.";
if(hasFiles) {
mail.execute(roothome);
}
appendLog( mail.parameters.text );
}
sendLog();
}
else {
appendLog("These items have a Group Name that does not behave:");
for each(var item in group) {
if(item["file"] == undefined) continue;
appendLog(" * " + item["file"]);
}
sendLog();
}
}
}
01-29-2009 04:56 PM
01-30-2009 09:56 AM
01-30-2009 11:07 AM
02-04-2009 04:14 PM
02-05-2009 04:32 AM
02-09-2009 01:04 PM
02-09-2009 01:47 PM
How the daily is triggered? Perhaps it runs as guest user?
By design the index is cutting the result list.
02-09-2009 01:49 PM
Is it possible to do a hibernate query from the Javascript API? A quick google search did not turn up much.
02-09-2009 05:18 PM
It is not "index" (I guess you meant Lucene query) which is cutting result list but rather acl evaluation.
Number of hits returned from Lucene is correct
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.