Help with the below Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 10:51 PM
Hi All ,
I am using the below script in one my function in my Business rule , the entire script is written in the function

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 10:55 PM
Hello @Pooja Khatri ,
Try Below fix
if (current.state.changes() && current.state == 'requested') {
// Get the event name to trigger.
var event = "approve.insert";
if (req) {
event = "req.approve.insert";
} else if (tsk) {
event = "tsk.approve.insert";
}
// Get the function return value.
var isNormal = change();
// Trigger the event only if the function returns true.
if (isNormal) {
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
}
// Update the task with the comment.
var cmt = getComment(isFD, getApproverUserName(current.approver), "Approve");
updateTask(current, cmt);
}
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 10:59 PM
Hi @Chetan Mahajan - with the above script will it only call event = approve.insert for is normal function and also will it not affect the other events and other conditions specified in the code ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 11:06 PM
Hello Pooja,
The event name will vary depending on the type of record being approved (e.g., request, task, etc.) if those not found it will call event = approve.insert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 11:07 PM
@Chetan Mahajan I tried with the given fix , but its not working