Commit d5bd22a6 authored by Frank Bergmann's avatar Frank Bergmann

Copied im_workflow__assign_to_supervisor from upgrade script to create script

parent 9c9d1b9b
......@@ -254,7 +254,7 @@ end;$$ language 'plpgsql';
-- ------------------------------------------------------
-- Unassigned callback that assigns the transition to the supervisor of the owner
-- of the underlying object
-- of the underlying object, or use custom_arg as a default
--
create or replace function im_workflow__assign_to_supervisor (integer, text)
returns integer as $$
......@@ -266,7 +266,7 @@ declare
v_journal_id integer; v_object_type varchar;
v_owner_id integer; v_owner_name varchar;
v_supervisor_id integer; v_supervisor_name varchar;
v_transition_key varchar;
v_transition_key varchar; v_default_party_id integer;
v_str text;
row RECORD;
begin
......@@ -298,6 +298,30 @@ begin
PERFORM workflow_case__add_task_assignment(p_task_id, v_supervisor_id, 'f');
PERFORM workflow_case__notify_assignee (p_task_id, v_supervisor_id, null, null,
'wf_' || v_object_type || '_assignment_notif');
return 0;
END IF;
RAISE NOTICE 'im_workflow__assign_to_supervisor(task_id=%, oid=%): No supervisor found, assigning to custom_arg="%" ',
p_task_id, v_object_id, p_custom_arg;
-- Cast to integer from parties.party_id. NULL argument gracefully handled or use global default
v_default_party_id := select party_id from parties where party_id::varchar = p_custom_arg;
IF v_default_party_id is null THEN v_default_party_id := select group_id from groups where group_name = 'Senior Managers'; END IF;
IF v_default_party_id is not null THEN
RAISE NOTICE 'im_workflow__assign_to_supervisor(task_id=%, oid=%): Assigning to party_id in custom_arg="%" ', p_task_id, v_object_id, p_custom_arg;
v_journal_id := journal_entry__new(
null, v_case_id,
v_transition_key || ' assign_to_default ' || acs_object__name(v_default_party_id),
v_transition_key || ' assign_to_default ' || acs_object__name(v_default_party_id),
now(), v_creation_user, v_creation_ip,
'No supervisor found, assigning to default party ' || acs_object__name(v_default_party_id)
);
PERFORM workflow_case__add_task_assignment(p_task_id, v_default_party_id, 'f');
PERFORM workflow_case__notify_assignee (p_task_id, v_default_party_id, null, null,
'wf_' || v_object_type || '_assignment_notif');
return 0;
END IF;
return 0;
end;$$ language 'plpgsql';
......
......@@ -52,8 +52,8 @@ begin
return 0;
END IF;
-- No supervisor found, assign to custom_arg party_id (user or group)
RAISE NOTICE 'im_workflow__assign_to_supervisor(task_id=%, oid=%): No supervisor of object creator, assigning to party_id in custom_arg="%" ', p_task_id, v_object_id, p_custom_arg;
RAISE NOTICE 'im_workflow__assign_to_supervisor(task_id=%, oid=%): No supervisor found, assigning to custom_arg="%" ',
p_task_id, v_object_id, p_custom_arg;
-- Cast to integer from parties.party_id. NULL argument gracefully handled or use global default
v_default_party_id := select party_id from parties where party_id::varchar = p_custom_arg;
......@@ -71,9 +71,8 @@ begin
PERFORM workflow_case__add_task_assignment(p_task_id, v_default_party_id, 'f');
PERFORM workflow_case__notify_assignee (p_task_id, v_default_party_id, null, null,
'wf_' || v_object_type || '_assignment_notif');
return 0;
END IF;
return 0;
end;$$ language 'plpgsql';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment