Durchsuchbare Dokumentation aufrufen | Zurück zur Dokumentationsübersicht
Navigation: Dokumentationen agorum core > Übersicht tags
Wenn zwei Objekte miteinander verknüpft wurden, können Sie die Verknüpfung über folgende Skripte wieder lösen.
/* global sc, sessionController */
let objects = require('common/objects'),
beans = require('common/beans');
let id1 = 'id-of-object-1'; // define id of first object
let id2 = 'id-of-object-2'; // define id of second object
let obj1 = objects.find(id1);
let obj2 = objects.find(id2);
obj1.removeAttachments([ obj2 ]);
obj2.removeAttachments([ obj1 ]);
'done';
/* global sc */
let objects = require('common/objects');
let beans = require('common/beans');
let obj = objects.find('9551365');
// holen
let att1 = objects.find('11911145'); // att1
// Ein Attachment setzen
obj.setAttachments([ att1 ]);
// Alle Attachments holen
let attributes = obj.allAttachments; // Hier kommt ein Array zurück
// Alle Attachments löschen
obj.removeAttachments(attributes);
Mit diesem Beispiel stellen Sie fest, ob ein Objekt eine Verknüpfung von einem anderen Objekt ist:
/* global sc */
let objects = require('common/objects');
let obj = objects.find('14181088713939');
let items = obj.attachedTo();
items.map(i => i.className + ', ' + i.name + ', ' + i.ID);
[ "WorkflowInstance, FileWorkflow214181088721943.txt, 14181088721943", "WorkflowInstance, Approval14181088722466.txt, 14181088722466" ]
/* global sc */
let objects = require('common/objects');
let obj = objects.find('14181088713939');
let items = obj.attachedTo();
// Alle Verknüpfungen löschen,
// an denen dieses Objekt hängt
items.forEach(function(item) {
item.removeAttachments([obj]);
});
// Alternative: Filter dazwischenschalten und prüfen, von welchen Objekten abgehängt werden soll
items.filter(item => item.className.toLowerCase() === 'WorkflowInstance'.toLowerCase()).forEach(function(item) {
item.removeAttachments([obj]);
});