Triggering custom Event from Workflow

Joe Taylor
Giga Guru

Hello,

  I'm trying to trigger a custom event from a specific workflow, but am having troulble.

  My catalog item "Employee Onboarding" triggers a workflow called "Employee Onboarding".

 The first step in the workflow is a group approval for the HR Dept.

  I want to send a custom email approval notification to this group from the sysapproval_approver table, not the OOB one.

  I have created a Notification called "Approval RITM for Onboarding".  

  This notification refers to an event I created in the Registry called "Employee_Onboarding_Approval".

  The issue is, I don't know how to trigger this event from my onboarding workflow approval step.

  I'm assuming I need to use a script in the "Advanced" box, but don't know exactly what it should say.

 Here's what I have so far:  gs.eventQueue('Employee_Onboarding_Approval',current,gs.getUserName(),gs.getUserID());

Help!

  

13 REPLIES 13

So if you do not want that, comment that triggering of event or change that event triggering of event to your event name.

Also i see that the notificaiton is on sysapproval_approver. Is yoru workflow also on sysapproval_approver. If not, then in the eventQueue function, you need to pass the object of sysapproval_approver and not current.

Joe Taylor
Giga Guru

Here are some excerpts from my business rule:

 

function checkSCRitm() {
var task = current.sysapproval.sys_class_name || current.source_table;
return (task == 'sc_req_item');
}

var isSCRitm = checkSCRitm();

 

if (current.state.changes() && current.state=='requested') {
var event = "approval.inserted";
if (isSCRitm)
event = "Employee_Onboarding_Approval";
//else if (isSCRitm)
//event = "ritm_approval";

}

 

This triggers the event I want.

However you see I had to comment out the general "ritm_approval" which I still need for other requested items.

How can I specify one event for "Employee_Onboarding_Approval"

and another one for just "ritm_approval" for everything else?

The Catalog item name is "Employee_Onboarding".

Before triggering the event, fetch the appropriate record from the table, and pass that Gliderecord object as a parameter to the event.

 

I just tweaked your code slightly. Check once. 

function checkSCRitm() {
var task = current.sysapproval.sys_class_name || current.source_table;
return (task == 'sc_req_item');
}

var isSCRitm = checkSCRitm();

if (current.state.changes() && current.state=='requested') {
  var event = "approval.inserted";
  if (isSCRitm) {
    if(current.group!='') {
      event = "Employee_Onboarding_Approval";
    } else {
      event = "ritm_approval";
    }
  }
}

Well, this sort of works.

It triggers the "Employee_Onboarding_Approval" event for any Group Approval step in any workflow.  Unfortunately, I need it to run only on this specific workflow.