Skip to content
Snippets Groups Projects
grantDeleteProcess.js 1.13 KiB
Newer Older
S.Listl's avatar
S.Listl committed
import("Entity_lib");
import("Employee_lib");
import("Context_lib");
import("system.vars");
import("system.result");

S.Listl's avatar
S.Listl committed
var contactId = vars.get("$field.CONTACTID");
var currentContext = ContextUtils.getCurrentContextId();

var canDelete = new HasLinkedObjectTester()
    .andNoEntityRows("Activity_entity", "LinkedObjects", {ObjectId_param : currentContext, RowId_param : contactId}) //Activities
    .andNoEntityRows("Task_entity", "Tasks", {ObjectId_param : currentContext, RowId_param : contactId}) //Tasks
    .andNoEntityRows("Document_entity", "Documents", {AssignmentTable_param : "CONTACT", AssignmentRowId_param : contactId}) //Documents
    .and(function () {return !EmployeeUtils.isUser(contactId);})
    .andNoEntityRows("Offer_entity", "ContactOffers", {ContactId_param : contactId}) //Offers
    .andNoEntityRows("Contract_entity", "Contracts", {ContactId_param : contactId}) //Contracts
S.Listl's avatar
S.Listl committed
    .andNoEntityRows("ObjectTree_entity", "TreeProvider", {ObjectIds_param : JSON.stringify([contactId, vars.get("$field.PERSON_ID")]), ObjectTypes_param : JSON.stringify([currentContext, "PrivatePerson"])})
S.Listl's avatar
S.Listl committed
    .validate();

result.string(canDelete);