How to Write Your First Rule in Guidewire ClaimCenter Using Gosu
![]() |
If you're starting a Guidewire career, you'll hear about rules within your first week. Business logic in ClaimCenter, such as validating a claim, assigning work or creating follow-up activities, is often handled by rules written in Gosu. This guide walks you through writing your first one.
What is a rule in Guidewire ClaimCenter?
A rule is a piece of business logic that ClaimCenter runs automatically at a specific point in the claim lifecycle. Each rule has two parts:
- Condition: a Gosu expression that returns true or false. It decides whether the rule applies.
- Action: the Gosu code that runs when the condition is true.
Rules are grouped into rule sets, and each rule set is tied to a particular event or purpose, such as validation, pre-update processing or assignment. Rules use Gosu, Guidewire's own object-oriented language, so a basic understanding of Gosu syntax will help a lot.
Before you start
You'll need:
- Access to a ClaimCenter development or training environment. Never practise in a shared or production environment.
- Guidewire Studio, the IDE used to configure the application.
- A basic understanding of the claim data model, such as claims, exposures and loss dates.
Step 1: Choose the right rule set
The first decision is where your logic should run. Ask yourself what should trigger it:
- Checking that data is correct before it's saved points to a validation rule set.
- Automatically changing or updating data when a claim is saved points to a pre-update rule set.
- Deciding who should handle a claim or task points to an assignment rule set.
Picking the wrong rule set is one of the most common beginner mistakes, so spend a minute on this step.
Step 2: Open the rule set in Studio
In Studio, navigate to the Rule Sets section of the configuration and open the rule set you chose. Exact folder names can vary slightly between versions, so check your version's configuration guide if something looks different.
Step 3: Create a new rule
Add a new rule inside the rule set and give it a clear, descriptive name. Rule names should tell the next developer exactly what the rule does, for example LossDateNotInFuture rather than Rule1.
Step 4: Write the condition
Let's build a simple validation: a claim's loss date shouldn't be in the future. The condition might look like this:
and claim.LossDate.after(gw.api.util.DateUtil.currentDate())Notice the null check first. Guarding against null values is a habit you'll be glad to build early.
Step 5: Write the action
When the condition is true, we want to flag the problem to the user:
"Loss date cannot be in the future", null, null)The exact method signature and validation levels depend on your ClaimCenter version and configuration, so confirm them in Studio's code completion or the Gosu and configuration documentation before using this in a real project.
Step 6: Test your rule
Run the application in your development environment, create or open a claim, and enter a future loss date. Confirm the message appears. Then test the opposite case with a valid date and a blank date, to make sure the rule stays quiet when it should.
Best practices for writing Gosu rules
- Keep conditions simple and readable. Complex logic is easier to maintain in a separate Gosu class that the rule calls.
- Handle nulls. Many ClaimCenter fields are optional.
- Write clear user-facing messages. Tell the user what's wrong and how to fix it.
- Avoid duplicating logic. If several rules need the same check, put it in a reusable method.
- Comment the business reason, not just the code.
- Follow your project's naming and coding standards.
Common beginner mistakes
- Putting logic in the wrong rule set.
- Forgetting null checks, which causes runtime errors.
- Writing heavy database queries inside rules, which can slow down claim processing.
- Hard-coding values that should live in typelists or configuration.
- Not testing edge cases.
Frequently asked questions
Do I need to know Java to write Gosu rules?
Not strictly. Gosu is its own language, though it runs on the JVM and will feel familiar if you know Java.
What's the difference between a rule and a Gosu class?
A rule runs automatically when its rule set fires. A class holds reusable code that rules, plugins and other components can call.
Can beginners practise Gosu without a live project?
Yes. A training or sandbox environment is the safest way to practise, ideally with guidance from an instructor or structured course.
Conclusion
Writing your first rule is a small step, but it teaches you how ClaimCenter thinks: events trigger rule sets, conditions decide, and actions do the work. Once this pattern feels natural, you'll be ready for more complex rules, activities and integrations.
Want to build these skills with hands-on guidance? Explore JastTech's Guidewire training programs and start practising on real project scenarios.










Comments
Post a Comment