Jamesbrendamour's picture
|
download
raw
3.58 kB
---
title: Smart Event Walkthrough | Sage Intacct Developer
url: https://developer.intacct.com/customization-services/smart-event-walkthrough/
---
# Smart Event Walkthrough | Sage Intacct Developer
Getting Started with Customization Services
Smart Event Walkthrough
Smart Event Examples
Synchronous API Smart Events
Smart Rule Examples
Customization Packages
* Overview
* Create a custom field
* Create the Smart Event
+ Conditions on the Smart Event
+ API body
* What’s next?
---
## Overview
As an introduction to the capabilities of Customization Services, let’s create a Smart Event that executes an internal API call after an object is created.
Specifically, we want to grab a field value from a related object (the customer) and use it to update an object we just created (an invoice).
We’ll need a create a custom field to hold the information garnered via the Smart Event.
## Create a custom field
You create a custom field in the Sage Intacct UI using the **Custom Fields** menu pick. For your reference, here’s an exported XML definition for the custom field on `ARINVOICE` used for this walkthrough.
```xml
<customField>
<customFieldId>CUSTOMER_REP</customFieldId>
<type>text</type>
<ownerObject>arinvoice</ownerObject>
<label>Customer rep</label>
<page>Header</page>
<dataDescription>
<text>
<length>50</length>
</text>
</dataDescription>
<required>false</required>
<description>For including Customer's sales rep</description>
<hidden>true</hidden>
<active>true</active>
</customField>
```
As you can see, the custom field’s ID is `CUSTOMER_REP`, and it is a hidden text field with a limit of 50 characters.
## Create the Smart Event
You create Smart Events in the Sage Intacct UI using a wizard available via the **Smart Events Catalog** menu. The wizard walks you through each step of the process:
* Choose the object to extend (`ARINVOICE`).
* Choose the type of action to perform (**API**), the trigger for the action (**Add**), and any conditions for the action.
* Provide the API body.
* Specify an ID for the Smart Event, a description, and a status (**Active**).
### Conditions on the Smart Event
We want the Smart Event to be triggered only when the total due for the invoice is greater than 3000. You can use the **Field Lookup** button on the Smart Event wizard to choose the correct injection parameter for this, as shown:
`({!ARINVOICE.TOTALDUE!} > 3000.00)`
See the Sage Intacct product help for more information about writing conditions.
### API body
The purpose of the Smart Event is to populate the `CUSTOMER_REP` custom field with the ID for the sales representative (`CUSTREPID`) for the related customer. We use an `update_invoice` API function whose `key` is the record number of the current invoice.
```xml
<update_invoice key="{!ARINVOICE.RECORDNO!}">
<customfields>
<customfield>
<customfieldname>CUSTOMER_REP</customfieldname>
<customfieldvalue>{!ARINVOICE.CUSTOMER.CUSTREPID!}</customfieldvalue>
</customfield>
</customfields>
</update_invoice>
```
The update provides a value for our custom field via an injection parameter that provides a path from the owning object to the related object to the desired field value.
**Note:** Be aware that injections work in the context of Smart Events, but are not supported in Web Services XML API calls that originate outside the Sage Intacct UI.
## What’s next?
* Check out the Smart Event examples for more ideas.
Provide feedback

Xet Storage Details

Size:
3.58 kB
·
Xet hash:
5bd93a593ab8deacf8592156f7b2f58ca94785c3eb70cf63de7f73723e4c58df

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.