BYRD - Administrator’s and Developer’s Guide

Workflow

Workflows are an instrument to customize your processes on the platform. To create custom workflows BYRD allows you to intercept certain actions by writing ruby routines, that respond to those actions.

To enable workflows an workflow script needs to be registered in the pim.xml of your Datamodel:

<pim>
    <workflow>/food-regulation-eu1169-workflow.rb</workflow>
</pim>

The following actions can be intercepted:


Action Key in Ruby-Script
An import has finished import_finished
An Inbound message was received inbound_message_received
The state of an inbound message changed inbound_message_status_changed
An item was saved item_saved
A outgoing publication is finished publication_finished
An item review was received review_received
A User signed up for your organization sign_up
A Subscription was created or changed subscription_saved
A Task comment was added task_comment_added
The status of a task has changed task_status_changed
The validation of an item is completed validation_finished
A user from your organization logged in user_login
A script threw an exception script_exception

Additionally there are three GDSN specific events, that are only fired in case of a GDSN connection:

Action Key in Ruby-Script
An outbound message was created outbound_message_created
The status of an outbound message was changed outbound_message_status_changed
A GDSN Response Message was received message_response_received
One response is processed response_message_received

When running in a GDSN context these events should be left, as implemented in the provided Datamodel.

Example

The following snippet shows an example workflow script with an implementation of the import_finished event:

# encoding: utf-8
# event: import_finished

case $event

when 'import_finished' then

  transitions = {
    :items_ok => 'Items are ok',
    :recheck_items => 'Please re-check items',
  }

  todo = {
    :title => "New Items imported",
    :gathering => $parameters['gathering'],
    :assignee => 'jdoe',
    :transitions => transitions
  }
  create_todo(todo)

end

The first two lines, tell the interpreter of the script about the events, being processed by the script:

# event: import_finished

when you temporarily want to disable the execution of an event you can achieve that, by changing this line to:

# event: DISABLED import_finished

The following lines shows how to react on certain events:

case $event
  when 'import_finished' then
  ...
  when 'some_other_event' then
  ...
end

The $event parameter specifies the event that should be executed by the script.

The complete list of parameters passed to the script is:

Paramter Description
$event The key of the event
$account The user that initiated the event
$organization Your organization properties
$parameters Hash of the parameters passed to the event