Create a New Dynamic URL Field

 import com.im.commons.db.ddl.GenericColumnType
 
// These imports are not necessary in 5.9 and later
import com.im.commons.progress.*
import com.im.df.api.capabilities.*
import com.im.df.api.util.*;
import com.im.df.api.ddl.*;
import com.im.commons.db.ddl.*;
import com.im.df.api.support.*;
 
def ety = dataTree.rootVertex.entity
ety.schema.lockable.withLock('Create a new dynamic URL field'){ envRW ->
// In IJC 5.11 and earlier
def Class[] req = [ DFFieldURLCapability.class ]
def Class[] excl = [ DBFieldCapability.class ]
def nt = DIFUtilities.findFirstAppropriateNewType(ety.getFields().getNewTypes(), false, req, excl)
nt.options.newDFItemNameSafe = "Search formula in google"
def DFField[] params = [ ety.fields.items.find { it.name == "Formula" } ]
nt.options.calcTemplate = CalcTemplate.create('http://www.google.com/search?q="{0}"', params)
nt.create(envRW)
// End of code for 5.11
 
// In IJC 5.12 and later
//def DFField[] params = [ ety.fields.items.find { it.name == "Formula" } ]
//DFFields.createDynamicURLField(ety, "Search formula in google", "text/html", 'http://www.google.com/search?q="{0}"', params, envRW)
// End of code for 5.12+
}