“Citizen developers” is a term often used today to describe individuals who leverage low or no-code options for customizing business applications without requirin...
“Citizen developers” is a term often used today to describe individuals who leverage low or no-code options for customizing business applications without requiring IT involvement. AI, like ChatGPT, is actively aiding Citizen Developers by breaking down the barrier of entry to writing custom code. Today we’ll walk through how to pair ChatGPT with Intacct Platform Triggers.
First, what are Platform Triggers?
In Release 3, 2022, Intacct made Platform Triggers generally available to standard objects (previously only available on custom objects). Triggers, like Smart Events, automate tasks upon a certain event’s occurrence. However, triggers are different from Smart Events in a couple of ways. First, not only can you select add, set, or delete actions but you can also choose whether the trigger occurs before committing the record to the database or after.
Events that can initiate a trigger:
- BEFORE CREATE
- BEFORE UPDATE
- BEFORE DELETE
- AFTER CREATE
- AFTER UPDATE
- AFTER DELETE
In addition to different events, triggers also allow for new action types.
Trigger types:
- Intacct API
- HTTP Post
- Send Email
- Validation
- Run Triggers on Related Objects
- Create New Record
- Update Field Value
- Attach Related Record
How do we apply these Platform Triggers and ChatGPT to a business use case?
In our use case, we’d like to post a journal entry to record commission based on the amount of a sales invoice. The first step is to calculate the amount of commission to post per invoice. Queue Platform Triggers. We’ll create a Platform Trigger on the Sales Invoice Header object that uses the BEFORE CREATE and BEFORE UPDATE events along with the Update Field Value action to perform a computation using simple JavaScript to update a custom field.
How do we build it?
First, the new custom field:
We will add a custom field called “Commission Amount” to the Sales Invoice Header object by going to Platform Services > + Custom Fields.
Now, let’s add the platform trigger to populate the new field:
First, navigation: from the Order Entry Transaction screen, go to More Actions > Object definition.
Click Triggers (top component list shortcut).
Then New trigger.
Next, select the trigger type “Update field value” and Next.
On the next page we’ll select the following properties:
- Trigger is Deployed – this activates the trigger. It can be deactivated at any time in the future by unchecking this box.
- Trigger Activation – In our use case, we would like the commission field to be updated both before create and before update.
- Trigger Name – UPDATE COMMISSION AMOUNT (not quite as finicky as smart events – these names can have spaces!)
- On Field Change – We’ll select Any Update to keep things simple here. However, you could have a trigger fire only upon certain fields being changed (a great example: information on a Vendor being changed could trigger an email)
- Record – should be already selected if you navigated from the sales invoice screen to the appropriate transaction definition.
- Field to Change – We want to update the new custom Commission Amount field.
- Change Value Formula – this is where we’ll leverage a little of Intacct’s help and ChatGPT.
Queue my conversation with ChatGPT:
Thanks to ChatGPT (thanking AI is always key) and a little of Intacct’s help guide I know the formula I need is:
As ChatGPT is not always right, it’s important to use Intacct’s help guide as well as the two steps available for debugging prior to saving the trigger and deploying it (and yes, always build and test in a sandbox first):
- Validate the syntax is correct. After clicking the magnifying glass, the green box around my formula signifies a correct formula.
- Debug by selecting an existing transaction to verify that the formula is evaluating as expected and returning the correct value. This magnifying glass brings up a new window which displays how the formula is parsed and the result for a specified transaction.
Lastly, let’s watch the new Platform Trigger in action!
(Yes, those are expensive binders and paper reams).
Final thoughts and what’s next?
While platform triggers do open up a wide array of options that were previously not available (hello JavaScript to compute formulas!), they do have limitations that ensure Smart Events will not yet completely be fading into the background. Namely, Platform Triggers that update fields cannot always traverse related objects. For example, I cannot populate a custom field on the Sales Invoice from a Customer, so yes you’ll still need this smart event to populate a tax ID or sales rep name on an invoice. Curious about other applications for triggers or have a use case you would like us to help test? Reach out to your Sage Intacct team!
Now that ChatGPT is writing code for us, and putting together our vacation itineraries, maybe we’ll all have a littler more time to attend webinars like our next one on Smart Events and Smart Rules on Tuesday, October 31st. Curious about other applications for triggers or have a use case you would like us to help test? Reach out to your Sage Intacct team!
The post ChatGPT and Intacct Platform Triggers appeared first on Sage Blog.
Want to learn more? Complete the form below and we'll be in touch. If you are unable to see the form below, please complete your submission here.Contact us