Absence Workflow Configuration

Triggering Workflows for Absences

In order to trigger a workflow for an absence please see How to trigger a Workflow

Configuring DELETE/EDIT options for active Absence Workflows

]po[ Workflow provides highly flexible configuration options for permission settings that are based on current workflow status and user permissions.

The availability of buttons DELETE/EDIT of the Absence Workflow Panel is set by a function as defined in the following parameters:

  • AbsenceNewPageWfEditButtonPerm (default: im_absence_new_page_wf_perm_edit_button) and
  • AbsenceNewPageWfDeleteButtonPerm (default: im_absence_new_page_wf_perm_delete_button)
 Absence Workflow Panel

                                                                                          Abb.: Absence Workflow Panel

Default configuration for the EDIT button is as follows (im_absence_new_page_wf_perm_edit_button):

Whereas permission table "im_absence_new_page_wf_perm_table" contains (by default) the following data structure to define the permissions:


Setting up custom tables to define availability of DELETE/EDIT buttons

In order to set up your own permission rules please follow instructions as given below:

1) Create a "Custom Package"

Use the OpenACS Package Manager (http://[YOUR_SERVER]/acs-admin/apm) to create a new package. You probably want to follow the ]po[ naming conventions and name this package "intranet-cust-[YOUR_COMPANY_NAME]"

2) Create a tcl file named [PACKAGE-NAME]-procs.tcl in directory ~/packages/[PACKAGE-NAME]/tcl/

3) In this package create a procedure named "im_absence_new_page_wf_perm_edit_button_custom" as follows:

    set req [im_absence_status_requested]
    set rej [im_absence_status_rejected]
    set act [im_absence_status_active]
    set del [im_absence_status_deleted]

    set perm_hash(owner-$rej) {v r d w a}
    set perm_hash(owner-$req) {v r d}
    set perm_hash(owner-$act) {v r d}
    set perm_hash(owner-$del) {v r d}

    set perm_hash(assignee-$rej) {v r}
    set perm_hash(assignee-$req) {v r}
    set perm_hash(assignee-$act) {v r}
    set perm_hash(assignee-$del) {v r}

    set perm_hash(hr-$rej) {v r d w a}
    set perm_hash(hr-$req) {v r d w a}
    set perm_hash(hr-$act) {v r d w a}
    set perm_hash(hr-$del) {v r d w a}

    set perm_table [array get perm_hash]
    set perm_set [im_workflow_object_permissions  -object_id $absence_id  -perm_table $perm_table]

    ns_log Notice "im_absence_new_page_wf_perm_edit_button absence_id=$absence_id => $perm_set"
    return [expr [lsearch $perm_set "w"] > -1]

4) Set the permissions accordingly.


To avoid that "owners" can edit the absence after it has been approved, rejected or deleted replace lines 

    set perm_hash(owner-$rej) {v r d w a}
    set perm_hash(owner-$req) {v r d}
    set perm_hash(owner-$act) {v r d}
    set perm_hash(owner-$del) {v r d }

with lines:

    set perm_hash(owner-$rej) {v }
    set perm_hash(owner-$req) {v d}
    set perm_hash(owner-$act) {v }
    set perm_hash(owner-$del) {v }

5) Set paramter AbsenceNewPageWfEditButtonPerm to: im_absence_new_page_wf_perm_edit_button_custom

6) Restart your web server and make sure that your new lib is compiled correctly (see ~/log/error.log for details)

7) Verify functionality


Other customization examples

Stored to procedure to set Dynfield 'Comments' with comments made by approver

CREATE OR REPLACE FUNCTION im_absence__add_comment(integer, character varying, character varying)
  RETURNS integer AS
        p_case_id               alias for $1;
        p_transition_key        alias for $2;
        p_custom_arg            alias for $3;

        v_task_id               integer;        v_case_id               integer;
        v_creation_ip           varchar;        v_user_id	        integer;
	v_creation_user		integer;
        v_object_id             integer;        v_object_type           varchar;
        v_journal_id            integer;
        v_transition_key        varchar;        v_workflow_key          varchar;
        v_group_id              integer;        v_group_name            varchar;
        v_task_owner            integer;

        v_absence_id            integer;
        v_description           text;
        v_msg 	                text;

        v_object_name           text;
        v_locale                text;
	v_action_pretty		text;

        RAISE NOTICE 'im_absence__add_comment: enter - p_case_id=%, p_transition_key=%, p_custom_arg=%', p_case_id, p_transition_key, p_custom_arg;

        -- Select out some frequently used variables of the environment
        select  c.object_id, c.workflow_key, co.creation_user, task_id, c.case_id, co.object_type, co.creation_ip
        into    v_object_id, v_workflow_key, v_creation_user, v_task_id, v_case_id, v_object_type, v_creation_ip
        from    wf_tasks t, wf_cases c, acs_objects co
        where   c.case_id = p_case_id
                and c.case_id = co.object_id
                and t.case_id = c.case_id
                and t.workflow_key = c.workflow_key
                and t.transition_key = p_transition_key;

        -- set absence_id
        v_absence_id := v_object_id;
	RAISE NOTICE 'im_absence__add_comment: v_absence_id:% ', v_absence_id;

	select 	owner_id, description
	into 	v_user_id, v_description
	from 	im_user_absences
	where 	absence_id = v_absence_id;

	-- get owner locale
        select  language_preference into v_locale
        from    user_preferences
        where   user_id = v_user_id;

        IF v_locale IS NULL THEN
                v_locale := 'en_US';
                RAISE NOTICE 'im_absence__add_comment: Missing language_preference for user_id:%', v_user_id;
        END IF;
	-- get comment
	v_action_pretty := p_custom_arg || ' finish';
	select msg into v_msg from journal_entries where object_id = v_case_id and action_pretty = v_action_pretty;

	-- RAISE NOTICE 'im_absence__add_comment: msg:% from action_pretty:% and absence_id:%', v_msg, v_action_pretty, v_absence_id;
	-- v_description := v_description || '\n\n' || acs_lang_lookup_message(v_locale, 'intranet-core', 'Comment') || ':\n\n' || v_msg;
	-- RAISE NOTICE 'im_absence__add_comment: New description:%', v_description;
	update im_user_absences set comments = v_msg where absence_id = v_absence_id;

        return 0;

  Contact Us
  Project Open Business Solutions S.L.

Calle Aprestadora 19, 12o-2a

E-08907 Hospitalet de Llobregat (Barcelona)

 Tel Europe: +34 932 202 088
 Tel US: +1 415 429 5995
 Mail: info@project-open.com