Professional Documents
Culture Documents
Gosu is Guidewire's programming language - Has elements of both procedural and object-oriented programming languages - Similar to JavaScript and Java
Gosu specifies runtime business logic that: - Executes fundamental application behavior - Manages complex business processes - Specifies dynamic client-side behavior
Enhancements
Classes
Gosu classes - Create general purpose classes, such as logging utilities, plugins, and entities used to pass information to external applications
PCFs
Workflows
Enhancements
Classes
PCFs
Workflows
1. Click the
"Disconnected" button
2. Enter login
print ( Strings_and/or_variables )
Lesson outline
Guidewire Gosu overview Gosu statements Gosu objects Gosu subtypes Studio features for working with Gosu
Variables
Syntax to declare variables:
variableName = newValue
Comments
Single-line comment // comment - CTRL + SHIFT + / toggles selected lines to have or not have single-line comments Multiple-line comment /* comment */
Statements
Statements in Gosu do not require a terminator to mark
end of statement
- Compiler determines end of statement based on syntax
statement
Common comparison operators: - Equality: ==, != - Relational: >, <, >=, <= - Compound: AND (or &&), OR (or ||)
Concatenation operator
Concatenates two or more values into a single string Syntax: value + value
if/else statements
Syntax: if (condition)
statement_or_{block} else
statement_or_{block}
Ternary operator
Similar to if-else, but can
statements
Typically used in PCF
Lesson outline
Guidewire Gosu overview Gosu statements Gosu objects Gosu subtypes Studio features for working with Gosu
Objects
Syntax to create new variable:
to given object
Syntax: objectName.fkeyFieldName.fieldName
Lesson outline
Guidewire Gosu overview Gosu statements Gosu objects Gosu subtypes Studio features for working with Gosu
Subtyped entities
Guidewire entities
ABContact
AssignedUser EmailAddress
inherits the properties and methods of all their supertypes - Subtypes typically have their own properties and/or methods
ABPerson
FirstName LastName
ABDoctor
DoctorSpecialty MedicalLicense
ABContact
JLee
Name: James Lee EmailAddress: null Subtype: ABDoctor FirstName: James Gender: male LastName: Lee MedicalLicense: AB3244
ABContact fields
(JLee as ABDoctor)
(next object)
subtype
indirectly reference fields and methods below that subtype by indicating child subtype where field is declared
Syntax: ( object as childSubtype ).fieldOrMethod
directly or indirectly
- Syntax: ( object typeis Subtype )
Lesson outline
Guidewire Gosu overview Gosu statements Gosu objects Gosu subtypes Studio features for working with Gosu
Syntax checker
Most Studio components that work with Gosu include a
syntax checker
- Green square indicates code is well-formed
- Red square indicates code has syntax error - One or more horizontal bars indicate lines with syntax errors - Mouse over horizontal bar to display popup with more details
Array length
Syntax:
array.length
parameter
Syntax:
parameter
Syntax:
parentObject.removeFromArrayName(objectToRemove)
Gosu queries
A Gosu query is an object associated with a specific entity
objects that does not exist as an array, such as "all contact notes created by this user"
table Coverage
query object
results object
clauses) to apply
they be ordered?
it were an array
Lesson outline
Gosu query basics Working with queries Working with result sets
Restricting queries
Query objects have methods that add restrictions to query - Typically, they become SQL where clause
Lesson outline
Gosu query basics Working with queries Working with result sets
Sorting results
Sorting methods use blocks as input parameters - Syntax: resultsObj.orderBy( \ row -> row.FieldName) resultsObj.orderByDescending( \ row -> row.FieldName )
queryObj.select().AtMostOneRow
- If single item exists, method returns that single row
Business rules
A business rule is Gosu code that: - Accomplishes some task for given entity, and - Executes when specific event occurs to instance of that entity TrainingApp Example - ABContact pre-update rules
- Execute actions required by change to an ABContact, such as:
- Creating history entry to record change of assigned user - Setting a company's Primary Contact to null if the original Primary
if
{ }
then
collection of rules that are attached to the same entity and share the same trigger
- For example,
ABContact Preupdate rule set is attached to ABContact and triggers when any ABContact is created or modified
a set of one or more lines of code that typically executes one logical action
Rules can have
child rules
- If parent
condition is true, parent action is executed and then child rules are executed
Rule names
Guidewire recommends rules naming convention be
Lesson outline
Business rules overview Rules-specific Gosu Working with rules Debugging rules
Root entity
Every rule set has "root entity" - Identifies entity with which rule set is associated Every rule has access to object that triggered rule set - Object has same name as root entity
When triggering event occurs: - Rules executed in order listed in Studio - If rule has child rules and parent rule condition is true, parent action executed first, then child rules executed - All rules in rule set executed unless explicit "exit" encountered
"Exit after first action" rule sets - When first true condition is found, action taken and rule set is exited - Example: assignment rules
- Once one assignment is made, rule set
sets
- Syntax: actions.exit()
- Example:
Lesson outline
Business rules overview Rules-specific Gosu Working with rules Debugging rules
Selecting the rule set displays rule set description and lists
root entity
Rules in Studio
Resources Rule Set tab Rule tab
Lesson outline
Business rules overview Rules-specific Gosu Working with rules Debugging rules
Studio debugger
The Studio debugger is a set of tools that
Setting breakpoints
should be suspended
- Once suspended, you can step through code and observe: - Which code gets executed - Variable and object values
number
running
To start debugger, select
Suspending execution
When application executes code
with breakpoint
- Execution is suspended
with current line in green - Frame tab shows current values of root and related objects
can:
- View values in
Watches
A watch is an expression
Start or continue debugging Stop debugging Step to next statement after current execution point
Stopping debugger
To stop debugger, click either Stop button
Methods
A method is a set of statements that executes a logical unit
of work
function popupButtonText If flag entry's IsEditable boolean is true return "View/Edit" Otherwise, return "View"
Method syntax
Can take input parameters, return a result, or both Syntax:
function functionName (inputvar : datatype) : returnType { // code to execute method return returnValue
input parameter
return value
gives error
Enhancements - Method associated to given type (such as an entity) - Can only be used by instances of that type - Discussed in "Enhancements" lesson
Classes - Method associated with given class - If declared as static methods, can be used anywhere - Discussed in "Gosu Classes" lesson
Lesson outline
Overview of Gosu methods Creating PCF methods Common use cases for PCF methods
PCF methods
A PCF method is a method declared on a given PCF file's
Code tab
- Method can be called by properties of PCF file or its widgets
Lesson outline
Gosu methods Creating PCF methods Common use cases for PCF methods
Action
Widget availability
An atomic widget's available property determines when the
available = false
Widget is clickable only if available returns true - Default value is true - Checked only when action property is not null CurrentLocation.InEditMode can be used to control
execute code when their value changes in the application (prior to the value being saved)
- This is discussed
Use case 4
PCF methods can be called in