AppScript Variables

/* * Typed Variables * A declared data point that may contain a value * May be used to give a static value a meaningful name * Also used for persisting dynamic values through a script */ boolean isTrue = true; boolean isFalse = false; char yes = 'Y'; char no = 'N'; int number = 10 ; int bigNumber 50268; int negativeNumber = -120; float decimal = 1.01; float fraction = 0.75; String address = "123 Main Street"; String fullName = "John Smith"; String phoneNumber = "(123) 555-5555"; List emptyList = []; List numberList = [1, 2, 3, 4, 5]; List stringList = ["thingA", "thingB", "thingC"]; List mixedList = [123, "John Smith", 1.75, 'Y']; List listOfMaps = [ [key: "value"], [key: "value"], [key: "value"] ]; Map emptyMap = [:]; Map person = [name: "John Smith", age: 50, address: "123 Main Street"]; Map mapOfMaps = [ keys: [ [key: "value"], [key: "value"] ], items: [ [item: "content"], [item: "content"] ] ]; Date today = new Date(); Date fiveDaysFromNow = new Date() + 5; Date yesterday = new Date() - 1; /* * Bind Variables * Special variables that are always available in AppScripts. * Used for accessing data in the underlying tables. */ /* * currentValues["Field"]; * A Map containing the values of the record that triggered the AppScript. * These values are accessed using a field or relationship name. */ currentValues["Field"] = "newValue"; /* * previousValues["Field"]; * A Map containing the values of the record that triggered the AppScript. * These values are accessed using a field or relationship name. * previousValues is only populated in before update and after update AppScripts. */ String oldValue = previousValues["Field"]; /* * childTables["Child Table"]["Relationship Name"]; * A List of Maps that will add child records to a parent. * When the AppScript finishes, these Maps are converted to child records. */ List children = childTables["Child Table"]["Relationship Name"] as List<Map>; children.add(["Field": "Value"]); /* * childRecords["Child Table"]["Relationship Name"]; * A List of Maps which represents a collection of child records. */ List<Map> children = childRecords["Child Table"]["Relationship Name"] as List<Map>; children.each { child -> logger.info(child.field) }