function checkEmptyString(x) {
return (null == x || typeof x == 'undefined' || undefined == x || 'null' == x || '' == x);
}
function getUserInfo(employeeId) {
var userInfo = employeeId;
if(null != employeeId && typeof employeeId != 'undefined' && undefined != employeeId) {
var user = tw.system.org.findUserByName(employeeId);
if(user != null) {
userInfo = user.fullName + " (" + employeeId + ")";
}
}
return userInfo;
}
var pendingWith = "";
if( !checkEmptyString(processId) ) {
try {
var search = new TWSearch();
search.organizedBy = TWSearch.OrganizeByTypes.Task;
var searchColumnList = new Array();
var conditionList = new Array();
// Task #
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.ID;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Task - AssignedToRole
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.AssignedToRole;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Task - AssignedToUser
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.AssignedToUser;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Add Conditions
// Task - Status Equals Received
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.Status;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = TWTask.Statuses.Received;
conditionList.push(condition);
// Process - Status Equals Active
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.ProcessInstanceColumns.Status;
searchColumn.type = TWSearchColumn.Types.ProcessInstance;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = TWProcessInstance.Statuses.Active;
conditionList.push(condition);
// Condition with Process Instance #
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.ProcessInstanceColumns.ID;
searchColumn.type = TWSearchColumn.Types.ProcessInstance;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = processId;
conditionList.push(condition);
search.columns = searchColumnList;
search.conditions = conditionList;
var results = search.execute();
if ( results && results.rows && results.rows.length > 0 ) {
for ( var i = 0; i < results.rows.length; i++ ) {
var values = results.rows[i].values;
for ( var j = 0; j < values.length; j++ ) {
var key = searchColumnList[j].type + "_" + searchColumnList[j].name;
if( key == 'Task_AssignedToRole' && !checkEmptyString(values[j]) ) {
pendingWith = (checkEmptyString(pendingWith)) ? (values[j] + " Team") : (pendingWith + ", " + values[j] + " Team");
}
else if( key == 'Task_AssignedToUser' && !checkEmptyString(values[j]) ) {
pendingWith = (checkEmptyString(pendingWith)) ? getUserInfo(values[j]) : (pendingWith + ", " + getUserInfo(values[j]));
}
}
}
}
}
catch ( Exception ) {
log.error("Process App : " + tw.system.model.processApp.acronym + ", Error while looking up pending with for Process # " + processId);
if( tw.system.error )
log.error("Error Details : " + tw.system.error.toString(false));
}
return pendingWith;
}
return (null == x || typeof x == 'undefined' || undefined == x || 'null' == x || '' == x);
}
function getUserInfo(employeeId) {
var userInfo = employeeId;
if(null != employeeId && typeof employeeId != 'undefined' && undefined != employeeId) {
var user = tw.system.org.findUserByName(employeeId);
if(user != null) {
userInfo = user.fullName + " (" + employeeId + ")";
}
}
return userInfo;
}
var pendingWith = "";
if( !checkEmptyString(processId) ) {
try {
var search = new TWSearch();
search.organizedBy = TWSearch.OrganizeByTypes.Task;
var searchColumnList = new Array();
var conditionList = new Array();
// Task #
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.ID;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Task - AssignedToRole
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.AssignedToRole;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Task - AssignedToUser
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.AssignedToUser;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
// Add Conditions
// Task - Status Equals Received
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.TaskColumns.Status;
searchColumn.type = TWSearchColumn.Types.Task;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = TWTask.Statuses.Received;
conditionList.push(condition);
// Process - Status Equals Active
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.ProcessInstanceColumns.Status;
searchColumn.type = TWSearchColumn.Types.ProcessInstance;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = TWProcessInstance.Statuses.Active;
conditionList.push(condition);
// Condition with Process Instance #
var searchColumn = new TWSearchColumn();
searchColumn.name = TWSearchColumn.ProcessInstanceColumns.ID;
searchColumn.type = TWSearchColumn.Types.ProcessInstance;
searchColumnList.push(searchColumn);
var condition = new TWSearchCondition();
condition.column = searchColumn;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = processId;
conditionList.push(condition);
search.columns = searchColumnList;
search.conditions = conditionList;
var results = search.execute();
if ( results && results.rows && results.rows.length > 0 ) {
for ( var i = 0; i < results.rows.length; i++ ) {
var values = results.rows[i].values;
for ( var j = 0; j < values.length; j++ ) {
var key = searchColumnList[j].type + "_" + searchColumnList[j].name;
if( key == 'Task_AssignedToRole' && !checkEmptyString(values[j]) ) {
pendingWith = (checkEmptyString(pendingWith)) ? (values[j] + " Team") : (pendingWith + ", " + values[j] + " Team");
}
else if( key == 'Task_AssignedToUser' && !checkEmptyString(values[j]) ) {
pendingWith = (checkEmptyString(pendingWith)) ? getUserInfo(values[j]) : (pendingWith + ", " + getUserInfo(values[j]));
}
}
}
}
}
catch ( Exception ) {
log.error("Process App : " + tw.system.model.processApp.acronym + ", Error while looking up pending with for Process # " + processId);
if( tw.system.error )
log.error("Error Details : " + tw.system.error.toString(false));
}
return pendingWith;
}