Language: Deutsch · English
Event rule „Create“: interface, context and an example – how to react to this Nuclos event.
REFERENZ DEVELOPER UPDATED: JUL 2026 APPLIES TO NUCLOS 4.2026.X
On this page
This server-side rule runs when a new record is created (before saving). It can be assigned to a business object.
Skeleton of the rule class (the rule editor creates it automatically):
package org.nuclet.lager;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.context.InsertContext;
import org.nuclos.api.exception.BusinessException;
import org.nuclos.api.rule.InsertRule;
/** @name
* @description
* @usage
* @change
*/
@Rule(name="AnlegenLagerposition", description="Anlegen einer Lagerposition")
public class AnlegenLagerposition implements InsertRule {
public void insert(InsertContext context) throws BusinessException {
}
}
Context: InsertContext
The context InsertContext provides the affected BusinessObject via context.getBusinessObject(...); the RuleContext functions (providers) are also available. A BusinessException aborts the operation.
Assign it to the target via drag-and-drop in the server rule manager. Optionally restrict execution to a status or an action; control the order with the arrow buttons.
Assignment of „Create“.
package org.nuclet.company;
import org.nuclos.api.rule.InsertRule;
import org.nuclos.api.context.InsertContext;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.exception.BusinessException;
import org.nuclos.api.provider.BusinessObjectProvider;
import org.nuclos.api.provider.QueryProvider;
/** @name
* @description
* @usage
* @change
*/
@Rule(name="Bestellpositionanlegen", description="Bestellpositionanlegen")
public class Bestellpositionanlegen implements InsertRule {
public void insert(InsertContext context) throws BusinessException {
Bestellung curBestellung = context.getBusinessObject(Bestellung.class);
// Create new 'Bestellposition'
Bestellposition newPos = new Bestellposition();
// Get Artikel and Lagerort for default
Artikel myArticle = QueryProvider.getById(Artikel.class, 40460000L);
Lager myLagerort = QueryProvider.getById(Lager.class, 40271111L);
newPos.setPositionsnr(0);
newPos.setBezeichnung("Standard Palette");
newPos.setArtikelId(myArticle.getId());
newPos.setAnzahl(1.0d);
newPos.setBemerkung("Automatische Position");
newPos.setLagerId(myLagerort.getId());
// Insert new element to Bestellung
curBestellung.insertBestellposition(newPos);
}
}