Moving Agenda Items In Batch
From C3 Wiki
[edit] Summary
This code allows you to move all of the agenda items on a current meeting to a different meeting in case the meeting is rescheduled or cancelled. The code below is designed to be run from the command console, although it could be modified slightly to run on an activity. In this case, you could design the activity to use targetEntity as the context for the old meeting and an attribute of the activity (of type meeting) as the new meeting.
As with any console script, do not run in production until you have thoroughly tested it in a duplicate, nonproduction environment.
[edit] Code Sample
//SEM 10-28-08:Move all Agenda items from one meeting to another meeting
//Script takes all agenda items from the old meeting and moves them to the new meeting.
//The meeting property of each agenda item is set to the new meeting.
//Optionally, you can remove all agenda items from the old meeting.
var oldMeeting = wom.getEntityFromString("com.webridge.entity.Entity[OID[C67A420C6E8E734F8F998C622318A3C5]]"); //OID of old meeting
var newMeeting = wom.getEntityFromString("com.webridge.entity.Entity[OID[3C79F1EE06FF7A418C560B49534C1487]]"); //OID of new meeting
var setAgendaItemsOldMeeting = oldMeeting.getQualifiedAttribute("customAttributes._attribute2"); //Update to match your configuration
var setAgendaItemsNewMeeting = newMeeting.getQualifiedAttribute("customAttributes._attribute2");
if (!setAgendaItemsNewMeeting) {
setAgendaItemsNewMeeting = wom.createTransientEntity("_Agenda Item");
setAgendaItemsNewMeeting = setAgendaItemsNewMeeting.createEntitySet();
newMeeting.setQualifiedAttribute("customAttributes._attribute2", setAgendaItemsNewMeeting);
}
?"Agenda Items in Old set: " + setAgendaItemsOldMeeting.elements.count() + "\n";
?"Agenda Items in New set: " + setAgendaItemsNewMeeting.elements.count() + "\n";
for (i=1; i<= setAgendaItemsOldMeeting.elements.count(); i++) {
var objAgendaItem = setAgendaItemsOldMeeting.elements.item(i)
objAgendaItem.setQualifiedAttribute("customAttributes._attribute0", newMeeting);
objAgendaItem.setQualifiedAttribute("owningEntity", newMeeting);
setAgendaItemsNewMeeting.addElement(objAgendaItem);
}
//Uncomment below to empty the agenda item set of the old meeting
//setAgendaItemsOldMeeting.removeAllElements()
?"Agenda Items in New set after additions: " + setAgendaItemsNewMeeting.elements.count() + "\n";
//reset html cache of meetings
sch.invalidateCache(""+oldMeeting);
sch.invalidateCache(""+newMeeting);
