- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 05:15 PM
Hi everyone,
I created a Record Producer, linked the Incident Table, but when the user submits it is not to create a record in the table, just send a Notification Email to the Group email, only this.
Business Rule Advanced:
(function executeRule(current, previous /*null when async*/) {
gs.eventQueue('send.message.notitication',current,gs.getUserDisplayName());
})(current, previous);
I had to create an event as I don't need to insert, delete or update any records on the table, because of this I'm using the event: gs.eventQueue()
There are attached print.
Could anyone support me, please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 06:49 PM
Hi, can you explain the logic behind using a record producer to send an email but nor creating a record from the producer?
You should be able to trigger a sysevent directly from your record producer script and do not need to use a business rule.
eventQueue() requires a glideobject but it does not have to be 'current' and you do not have to utilize it in the notification processing, but I believe that the object will decide the table that your notification needs to be triggered from and any email variables used in the message would be mapped to this record, so recipients and content will need to be derived from parms 1 & 2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 09:17 PM
Another question would be: have you tried moving the code into the Producer script? In it you can use variable cat_item readily available:
gs.eventQueue('sendEmailToDepartment', cat_item, gs.getUserDisplayName());
Assuming the 3rd parameter, parm1 will be the recipient, you should return the user's sys_id or e-mail. I don't think the user's name will be transformed into an e-mail address - this could also be a reason why the notification is not created: there are no recipients.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 06:00 PM
As far as I can tell, after query business rules are not executed. It wouldn't make any sense to execute those after the select happened, cause the reason for query business rule is to filter what will be selected. Once the selection is done, no more filtering can happen.
Generally speaking, considering that Business Rules are executed around database operations, given that a record is not created, the only database operation that can happen is a database read - that of a new record.
But even if you turned the BR into a before display one, I don't think the notification will work without the record the event specifies - it has never existed.
All in all this is really something should not be done and can easily be avoided switching the target table to table interaction or table ticket. The 1st one is meant exactly for that: to register any kind of contact, even those that are not incidents. The 2nd one is not user for anything, so you could reuse it to actually create a record and do it right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 04:50 PM
Hi @-O- , how are you?!
I understood what you explained, there has to be a registration... due to that, I associated my RP to SC_Cat_Item table, created an event in the "Event Register" > BR after the register was inserted and associated it to the event > Notification via email to user and (Business Rule Advanced tab):
(function executeRule(current, previous /*null when async*/) {
gs.eventQueue('sendEmailToDepartment',current,gs.getUserDisplayName());
})(current, previous);
The record is being created in the table, but it does not send notification, but unfortunately it didn't work.
Thank you very much for your explanation!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 09:07 PM
The record is being created in the table
Can you say in which table? In the end you have decided to let the record be created?
I mean the business rule uses current as record associated with the event. But on the other hand you say you have configured event and notification to use sc_cat_item as record type. That would meant the users create Catalog Items when they submit this record producer, which I believe must not be what happens.
Also how exactly are you preventing the record from being created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 03:49 PM
Hi @-O- , how are you?!
When I created the RP, I associated it with the "Incidents" table and then the "sc_cat_item" table, but after analyzing the situation and all the responses I got, I decided to use the RP in the traditional way, causing the record to be created in the table (using event, business rule and notification). Thanks for your support.