Newer
Older
import("system.vars");
import("system.result");
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
.andNoEntityRows("ObjectTree_entity", "TreeProvider", {ObjectIds_param : JSON.stringify([contactId, vars.get("$field.PERSON_ID")]), ObjectTypes_param : JSON.stringify([currentContext, "PrivatePerson"])})