fire an event with business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:17 AM - edited 09-23-2024 04:40 AM
I want to delete a record under conditions ( in the business rules)
how to pass the record id to the event ?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:19 AM
Hi @ammar_k ,
Your description seems to be empty.Im not sure what you are asking is
But if you want to fire an event from BR use gs.eventQueue() method
Eg:gs.eventQueue("Event name","Object","Parm1","Parm2")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:21 AM
Hi,
You can use the below script to do so
gs.eventQueue('event_name', gliderecord_object, 'string_parm1', 'string_param2', 'string_queue')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 05:33 AM
Hi @ammar_k
If you want to pass current record sysid in event. You can write as written below.
gs.eventQueue('event_name', current, parmeter1, parmeter2);
Regards,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 06:11 AM - edited 09-23-2024 06:15 AM
I used this
if (gs.nil(condition)) {
gs.addInfoMessage('This record is empty and will be deleted in 30 minute if not updated.');
// Fire the event to delete the empty problem after 30 minute
var thirtyMinutesFromNow = new GlideDateTime();
thirtyMinutesFromNow.addMinutes(30);
// Fire the event and pass the sys_id of the current record
gs.eventQueueScheduled(
'Event name', // Event name
current, // GlideRecord object (problem record)
current.sys_id, // Parm1: sys_id of the record
null, // Parm2
thirtyMinutesFromNow // Scheduled time (1 minute from now)
);
}
})(current, previous);
then i used this script action :
(function executeDeleteRecord(event) {
var recordSysId = event.parm1; // Get the sys_id of the record from the event
var recordGR = new GlideRecord('record');
if (recordGR.get(recordSysId)) {
// Check if the record is still empty before deletion
if (gs.nil(condition)) {
gs.log('Deleting empty record: ' + recordGR.getUniqueValue());
recordGR.deleteRecord(); // Delete the empty record
}
}
})(event);
this sysId of the record is always undefined ( in the event and the action script)