**Source URL:** https://general.veevavault.dev/medical/vault-sdk/getting-started/write-custom-code.md

# Write Custom Code



In this step, you will:

* Write custom code that modifies the behavior of the sample record trigger

* Understand how to write code for different record events

With the development environment set up, you can now modify the `HelloWorld` trigger in your IDE.

Right now, the `HelloWorld` trigger has custom logic on the `BEFORE_INSERT` event.
In this step, you will add new custom code to trigger on the `AFTER_INSERT` event.
We’ve already written most of this code for you, so you can focus on the structural updates needed to add code for a new event on an existing trigger.

Unlike the `BEFORE_INSERT` event which triggers right before the record saves, the `AFTER_INSERT` event triggers immediately after the record saves.
When triggered, this new custom code creates a `vsdk_hello_world_child__c` record.

## Add Custom Code for the AFTER_INSERT Event {#add-custom-code-for-the-after_insert-event}

<Steps>
1. In IntelliJ®, navigate to your project’s home directory.

2. Open the `HelloWorld` Java file, which is located in `\src\main\java\com\veeva\vault\custom\triggers`.

3. Remove the multi-line comment (`/*`) on lines 35 and 74. This will uncomment lines 35 through 51, which is code for custom logic on the `AFTER_INSERT` event.<ThemeImage srcLight="/images/sdk/getstarted/DeleteMultilineCodeComment35.png" srcDark="/images/sdk/getstarted/DeleteMultilineCodeComment35.png" alt="Deleting multiline code comments."></ThemeImage>

4. Before this `AFTER_INSERT` code will run, you need to add this event to the record trigger annotation. You can do this by adding the event to the `@RecordTriggerInfo` annotation. In line 13, add `RecordEvent.AFTER_INSERT` to the `event` parameter in the annotation:<ThemeImage srcLight="/images/sdk/getstarted/AddingAFTERINSERT.png" srcDark="/images/sdk/getstarted/AddingAFTERINSERT.png" alt="Adding the AFTER_INSERT event to the record trigger annotation."></ThemeImage>

</Steps>
You’ve just written your first piece of SDK code, custom logic for an `AFTER_INSERT` event! In the next step, you will deploy these changes to your Vault.

## Continued Learning {#continued-learning}

* Learn more about the `@RecordTriggerInfo` annotation and how this works together to build the [anatomy of a record trigger](/vault-sdk/entry-points/triggers/record-triggers/anatomy-record-triggers/)

* Learn more about the [data availability of record trigger events](/vault-sdk/entry-points/triggers/data-availability/), which can help you choose if you need your custom code to trigger on a `BEFORE_INSERT` or` AFTER_INSERT` event



---

**Previous:** [Development Setup](/medical/vault-sdk/getting-started/development-setup)  
**Next:** [Deploy Custom Code](/medical/vault-sdk/getting-started/deploy-code)