A code sample worth a thousand words:
def qty = api.integerUserEntry("Quantity") // set up the user input as usual def p = api.getParameter("Quantity") // retrieve the context parameter with the same name as the input if (p != null && p.getValue() == null) { p.setLabel("Quantity (default: 1)") // set the displayed label p.setRequired(true) // set the mandatory hint p.setReadOnly(false) // set the read only flag p.setValue(1) // set the default value with which the input is pre-populated } return qty ?: 1 // if user doesn't specify a value, return 1
The same approach works for combo boxes:
def competitorNames = [ "SODEXO", "COMPASS" ] def competitor = api.option("Competitor", competitorNames) def p = api.getParameter("Competitor") if (p != null && p.getValue() == null) { p.setLabel("Primary Competitor") p.setValue(competitorNames[0]) } return competitor
There are many more properties you can change. For the complete list of available methods see the latest documentation on the ContextParameter class.