Rule snippets
From iDempiere en
Rule snippets
Enforce current date
To enforce POS-orders to be completed only with the current date the following snippet was attached to c_order on before complete:
import org.compiere.util.Env; today = Env.getContextAsDate(A_Ctx, "#Date"); today.setHours(0); today.setMinutes(0); today.setSeconds(0); today.setNanos(0); if (A_PO.getDateOrdered().before(today) && A_PO.getC_DocTypeTarget_ID() == 1000041) msg = "POS-Aufträge nicht für zurückliegende Daten"; else msg = ""; return msg;
Of course the doctype ID must be adjusted to your installation. The usage auf #Date instead of the systemtime allows to use an older date by setting it at login if required.
See Also
- Script Process for event rule example from a Report & Process window.
- Script ModelValidatorLogin
- Script Callout
