Step 7: Create a Python File - j5 - 28.0 - Help - Hexagon PPM

j5 BPMN Workflow Configuration

Language
English (United States)
Product
j5
Search by Category
Help
j5 Version
2019

Next you will need open the IDE again to create a Python file in Module directory. This will instruct the j5 system to use the necessary j5 BPMN library required to interpret the BPMN workflow diagrams. This is also where you can define custom methods to execute tasks within j5. To do this:

  1. Navigate to the Files tab

  2. Right click the Module name

  3. Select "New File..." from the context menu

  4. Name the new file "<module name>.py" (where <module name> is the name of the Module)

Update the contents of the Python file as follows:

  1. Double-click the file "<module name>.py" (where <module name> is the name of the Module)

  2. Copy the text below into the right­hand panel

  3. Save the file by clicking the Save icon

from sjsoft.BpmnWorkflow.WorkflowManager import EmbeddedWorkflowMixin

class EnvironmentalIncidentsMixin (EmbeddedWorkflowMixin):

def method_placeholder(self):

pass

# Additional method definitions here

The j5 standard naming convention is to call the Python Class : "<Module name>Mixin.py"

The "method_placeholder" method is a placeholder method, and can be over­written.

Tutorial Example:

  1. Create a Python file under the EnvironmentalIncidents module, and call this file "EnvironmentalIncidents.py".

    environmental-incidents-file

  2. Open the file, and paste the code below:

    from sjsoft.BpmnWorkflow.WorkflowManager import EmbeddedWorkflowMixin

    class EnvironmentalIncidentsMixin(EmbeddedWorkflowMixin): def update_fields_on_approval(self, sa_session):

    # Update Approved On (Date)

    from j5.OS import datetime_tz

    self.approved_on = datetime_tz.datetime_tz.now()

    # Update Approved By (User)

    from j5.Web.Server import RequestStack

    session = RequestStack.request_stack.session

    self.approved_by = session.user

    # Update Flag

    self.approved_flag = "Approved"

    # Update report message

    additional_text = " [Approved message]"

    self.report_message += additional_text

  3. Click Save

For more information on j5 Python method examples, please see j5 Python Methods References.