EPSPPMUtil.prototype = {
initialize: function() {},
checkVendorAccess: function() {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
if (currentCompany && currentCompany.vendor) {
return false;
} else {
return true;
}
},
checkVendorAccessToCostPlan: function(costTypeCompany) {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
//gs.log("gethere0 costTypeCompany: "+costTypeCompany);
//gs.log("ID : "+current.task.number);
//gs.log("ID Task : "+current.u_demand_task.number);
// is vendor
if (currentCompany && currentCompany.vendor){
//is lead SD or is collborator or part of assignment group of demand task
//gs.log("****** assignmentGroup" + current.u_demand_task.assignment_group.name );
if (current.task.assigned_to==gs.getUserID() || current.task.collaborators.includes(gs.getUserID()) || current.task.u_collaborators.includes(gs.getUserID()) || currentUser.isMemberOf(current.u_demand_task.assignment_group)){
//for vendors - check if vendor company matches cost type company, or cost type company is empty (in case of fixed cost type)
//gs.log("gethere1 currentCompany.name: "+currentCompany.name);
if (currentCompany.sys_id == costTypeCompany || costTypeCompany == ''){
//gs.log("gethere2");
return true;
} else if(currentUser.hasRole('u_dmn_cost_vendor_exempt') ){//allow to see cost
return true;
}else return false;
} else {
return false;
}
}else{
return true;
}
},
checkVendorAccessToDemand: function() {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
//check if user is vendor that does not have access
if (currentCompany && currentCompany.vendor) {
//check if user is granted exemption and is the lead solution designer of demand
if(currentUser.hasRole('u_dmn_vendor_exempt')){
//allow user to see demand task
if(current.assigned_to == gs.getUserID() || current.parent.assigned_to == gs.getUserID() || current.collaborators.includes(gs.getUserID()) || current.parent.collaborators.includes(gs.getUserID())){
return true;
}else{
//allow user to see cost
if(currentUser.hasRole('u_dmn_cost_vendor_exempt') && (current.task.assigned_to == gs.getUserID() || current.task.collaborators.includes(gs.getUserID()))){
return true;
}else return false;
}
}else{
return false;
}
} else {
return true;
}
},
checkVendorAssignmentGrp: function(assignmgtGrp) {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
if (currentCompany && currentCompany.vendor) {
//for vendors - check if part of group
if (currentUser.isMemberOf(current.getValue(assignmgtGrp))) {
return true;
} else return false;
} else {
return true;
}
},
checkVendorAssignmentGrpDmdTsk: function() {
var assignmgtGrp = current.getValue('assignment_group');
gs.log('Assignment Group: '+assignmgtGrp,'VendorRestriction');
var currentUser = gs.getUser();
var userCompanyID = currentUser.getCompanyID();
gs.log('User Company ID: '+userCompanyID,'VendorRestriction');
if(currentUser.hasRole('u_dmn_vendor_exempt')){ //If user has vendor exemption role, give access to all DTASKs.
return true;
}
if(current.assigned_to == currentUser || current.parent.assigned_to == currentUser || current.collaborators.includes(currentUser) || current.parent.collaborators.includes(currentUser)|| currentUser.isMemberOf(assignmgtGrp) || currentUser.isMemberOf(current.getValue('u_ccb_approval_group'))){
return true;
}
var currentCompany = new GlideRecord('core_company');
currentCompany.addEncodedQuery('vendor=true^sys_id='+userCompanyID);//User's company is a vendor
currentCompany.query();
if (currentCompany.next()){
var currentAssignmentGroup = new GlideRecord('sys_user_group');
currentAssignmentGroup.addEncodedQuery('u_vendor_company='+userCompanyID+'^sys_id='+assignmgtGrp);//Assignment group vendor company is user's company
currentAssignmentGroup.query();
if (currentAssignmentGroup.next()){
return true;
}
}
else{
return true;//If user's company is not a vendor company, grant access
}
return false;//If none of the above conditions are met, DO NOT grant access
},
checkVendorCostPlanAssignmentGrp: function(assignmgtGrp) {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
if (currentCompany && currentCompany.vendor) {
//for vendors - check if part of group
if (currentUser.isMemberOf(assignmgtGrp)) {
return true;
} else return false;
} else {
return true;
}
},
checkVendorCostType: function(costTypeCompany) {
var currentUser = gs.getUser();
var currentCompany = new GlideRecord('core_company');
currentCompany.get(currentUser.getCompanyID());
//gs.log("gethere0 costTypeCompany: "+costTypeCompany);
if (currentCompany && currentCompany.vendor) {
//for vendors - check if vendor company matches cost type company, or cost type company is empty (in case of fixed cost type)
//gs.log("gethere1 currentCompany.name: "+currentCompany.name);
if (currentCompany.sys_id == costTypeCompany || costTypeCompany == ''){
//gs.log("gethere2");
return true;
} else{
//allow user to see cost
//if(currentUser.hasRole('u_dmn_cost_vendor_exempt') && (current.task.assigned_to == gs.getUserID() || current.task.collaborators.includes(gs.getUserID()))){
//return true;
//}else
return false;
}
} else {
return true;
}
},
isRequestApprovalApproved: function(demandRec) {
var demandID = new GlideRecord('dmn_demand');
demandID.get(demandRec);
if ((current.assigned_to == gs.getUserID() || current.demand_manager == gs.getUserID()) && (demandID.u_substate == 'Impact Assessment' && demandID.state != 8)&&(demandID.state != 5) && (demandID.state !=12)) {
var taskgr = new GlideRecord('dmn_demand_task');
taskgr.addEncodedQuery('parent=' + demandRec.toString());
taskgr.addEncodedQuery('categoryINHLIA,HLSD,vendor_assessment,initial_review');
taskgr.query();
while (taskgr.next()) {
if (taskgr.category == 'vendor_assessment' && taskgr.state != 7 && taskgr.state != 3) {
return false;
}
}
return true;
} else {
return false;
}
},
myapprovalsMenu: function(){
var flag = false;
var menurole= gs.getProperty('hasrole.myapproval');
var arrRole=menurole.split(',');
for (var i=0;i<arrRole.length;i++ )
{
if(gs.hasRole(arrRole[i])){
flag = true;
}
}
gs.log("abcd role"+flag);
return flag;
},
// Confirm Requirements, HLSD, HLIA
checkDemandTaskUIAccess: function(demandTaskRec) {
if(
(current.state == 1 || current.state == 2)
&& (current.assigned_to == gs.getUserID()||current.parent.assigned_to==gs.getUserID()||current.parent.demand_manager==gs.getUserID())
|| (current.additional_assignee_list!='' && current.additional_assignee_list.indexOf(gs.getUserID()) != -1)
//|| (current.parent.collaborators!='' && current.parent.collaborators.indexOf(gs.getUserID()) != -1)
)
{
return true;
}
else
{
return false;
}
},
//TSSR, Security, Insurance, Vendor Impact Assessment - Close Skip and Close Complete
checkIADemandTaskUIAccess: function(demandTaskRec) {
if(current.assigned_to == gs.getUserID() || current.parent.assigned_to==gs.getUserID() || current.parent.demand_manager==gs.getUserID() || gs.getUser().isMemberOf(current.assignment_group.toString()) || (current.additional_assignee_list!='' && current.additional_assignee_list.indexOf(gs.getUserID()) != -1) || (current.parent.collaborators!='' && current.parent.collaborators.indexOf(gs.getUserID()) != -1))
{
return true;
}
else
{
return false;
}
},
// Vendor Impact Assessment - On hold, Resume, Accept, Reject, Re-est buttons
checkLSDIADemandTaskUIAccess: function(demandTaskRec) {
if(current.parent.assigned_to==gs.getUserID() || current.parent.demand_manager==gs.getUserID() || (current.additional_assignee_list!='' && current.additional_assignee_list.indexOf(gs.getUserID()) != -1) || (current.parent.collaborators!='' && current.parent.collaborators.indexOf(gs.getUserID()) != -1))
{
return true;
}
else
{
return false;
}
},
type: 'EPSPPMUtil