Callout for Auto-Filling Warehouse

Ray Lee ✓ Verified Java Plugin Development 2026-03-02

A model callout class that automatically sets the warehouse (M_Warehouse_ID) based on the selected organization in an order or invoice. Demonstrates the IColumnCallout interface pattern used in iDempiere for field-level business logic triggers.

Code
public class CalloutWarehouseDefault implements IColumnCallout {

    @Override
    public String start(Properties ctx, int WindowNo,
                        GridTab mTab, GridField mField,
                        Object value, Object oldValue) {

        if (value == null)
            return "";

        int orgId = (int) value;

        // Find default warehouse for organization
        String sql = "SELECT M_Warehouse_ID FROM M_Warehouse "
                   + "WHERE AD_Org_ID = ? AND IsActive = 'Y' "
                   + "AND IsDefault = 'Y'";

        int warehouseId = DB.getSQLValue(null, sql, orgId);

        if (warehouseId > 0) {
            mTab.setValue("M_Warehouse_ID", warehouseId);
        }

        return "";
    }
}

You Missed