- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 07:25 AM
Hey,
I have a busineness rule to fire event on insert to
(function executeRule(current, previous /*null when async*/) {
if (current.getTableName() == 'sys_journal_field' && current.operation() === 'insert')
gs.eventQueue("cato.sys_journal_field.inserted", current, gs.getUserID(), gs.getUserName());
if (current.getTableName() == 'sys_journal_field' && current.operation() === 'update')
gs.eventQueue("cato.sys_journal_field.updated", current, gs.getUserID(), gs.getUserName());
})(current, previous);
Thank you,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 07:44 PM
Yes, you can add a condition to your business rule to check if the "name" field of the sys_journal_field record is equal to "incident" before firing the event:
(function executeRule(current, previous /*null when async*/) {
if (current.getTableName() == 'sys_journal_field') {
if (current.operation() === 'insert' && current.name == 'incident') {
gs.eventQueue("cato.sys_journal_field.inserted", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() === 'update' && current.name == 'incident') {
gs.eventQueue("cato.sys_journal_field.updated", current, gs.getUserID(), gs.getUserName());
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 07:28 PM
Hi @EvgeniyG you can do like below name field on journal table holds table name
if (current.getTableName() == 'sys_journal_field' && current.name == 'incident' && current.operation() === 'insert')
gs.eventQueue("cato.sys_journal_field.inserted", current, gs.getUserID(), gs.getUserName());
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 07:44 PM
Yes, you can add a condition to your business rule to check if the "name" field of the sys_journal_field record is equal to "incident" before firing the event:
(function executeRule(current, previous /*null when async*/) {
if (current.getTableName() == 'sys_journal_field') {
if (current.operation() === 'insert' && current.name == 'incident') {
gs.eventQueue("cato.sys_journal_field.inserted", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() === 'update' && current.name == 'incident') {
gs.eventQueue("cato.sys_journal_field.updated", current, gs.getUserID(), gs.getUserName());
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 02:04 AM
Hi @EvgeniyG ,
In this optimized version, the conditions for the table name, operation type, and the "name" field value are combined into a single if statement. Additionally, the event name is dynamically generated based on the operation type (insert or update). This results in a more streamlined and efficient code while still achieving the desired functionality.
(function executeRule(current, previous /*null when async*/) {
if (current.getTableName() == 'sys_journal_field' && (current.operation() === 'insert' || current.operation() === 'update') && current.name == 'incident') {
gs.eventQueue("cato.sys_journal_field." + current.operation(), current, gs.getUserID(), gs.getUserName());
}
})(current, previous);
Please mark this response as helpful if your question has been answered correctly.