Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Updating Workflow Variable from Task

Derek AndersonJan 25 2024 — edited Jan 25 2024

I need to update a Workflow Variable from my Task. However, when I run an Action from my Task to update the Workflow Variable, I get an error indicating that Workflow Variables can only be updated by Business Administrators. The action appears to be running by “nobody” instead of a specific user. I have added both my user (who is the Potential Owner / Task Owner) as well as “nobody”, but the action still errors with the same message.

Here is my PL/SQL in the action is of type Execute Code on event On Create:
apex_workflow.update_variables(
p_instance_id => :APEX$WORKFLOW_ID,
p_changed_params => apex_workflow.t_workflow_parameters(
1 => apex_workflow.t_workflow_parameter(static_id => 'LRA_WORKFLOWID', string_value => :APEX$WORKFLOW_ID)));

Here is the error in Debug:
Exception in "begin apex_workflow.update_variables(
p_instance_id => :APEX$WORKFLOW_ID,
p_changed_params => apex_workflow.t_workflow_parameters(
1 => apex_workflow.t_workflow_parameter(static_id => 'LRA_WORKFLOWID', string_value => :APEX$WORKFLOW_ID)));
end;":
Error Stack: ORA-20987: APEX - Variables of Workflow 6962951866682401 can only be updated by a Business Administrator defined for the workflow - Contact your application administrator.
ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1111
ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1569
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5878
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5898
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW_API", line 141
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_230200", line 810
Backtrace: ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1111
ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1569
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5878
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5898
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW_API", line 141
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_230200", line 810
ORA-06512: at "APEX_230200.WWV_FLOW_DYNAMIC_EXEC", line 2607
ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1111
ORA-06512: at "APEX_230200.WWV_FLOW_ERROR", line 1569
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5878
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW", line 5898
ORA-06512: at "APEX_230200.WWV_FLOW_WORKFLOW_API", line 141
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_230200", line 810
ORA-06512: at "APEX_230200.WWV_FLOW_DYNAMIC_EXEC", line 2607

Screenshot of Debug viewer showing the User as nobody for the identifier 8033 listed above

Thank you

This post has been answered by Ananya Chatterjee-Oracle on Jan 27 2024
Jump to Answer

Comments

Hi @danderson27 ,

Yes you wouldn't be able to do it via the update_workflow_variable API as this is restricted only for the Workflow Administrator.

But you could try the following in your Action code

:LRA_WORKFLOWID = :APEX$WORKFLOW_ID ;

By the way,which Task event is this action associated with?

Thanks

Ananya

Derek Anderson

Trying to set the workflow ID was simply as a demonstration of what I'm trying to do.

I've tried the On Create, On Reject and On Parameter Update.

I'm trying to take input from the user (Reason for Rejection) and make it available to the next task.

Answer

Hi,

I tried this use-case on my end and here is how you can achieve it.

  • In your task definition, create a parameter REASON and set its Updatable flag to true/yes.
  • In your workflow
    • create a variable called REJECT_REASON of type VARCHAR2 initialized to Null.
    • create a variable called TASKID of type NUMBER initialized to Null.
    • for the Human Task workflow activity
      • set the Task ID Item attribute to TASKID.
      • set the Reason Task Parameter to Null.

Presuming that you have a Switch Activity after the Human Task Activity, which uses the Task Outcome as condition, create a new Workflow Activity of type Execute Code on the Reject Branch (Connection) leading out of the Switch Activity.

In the Execute Code activity (you can name it Set Rejection Reason) , type in the following code

begin
:REJECT_REASON := apex_approval.get_task_parameter_value(p_task_id => :TASKID, p_param_static_id => 'REASON');
end;

At runtime, before rejecting the task, update the Task Parameter Reason with the reason text and only after that Reject the task. You will find that the workflow variable REJECT_REASON is correctly updated.

Hope this helps.

Regards,

Ananya

Marked as Answer by Derek Anderson · Jan 29 2024
Derek Anderson

Thank you, This worked.

1 - 4

Post Details

Added on Jan 25 2024
4 comments
1,093 views