How to set Process Variable when I start a workflow??

Options
freddybrito
edited October 10, 2008 in Documentum #1

hi,Experts.

I have a question which cost me 2 days but still exist.

I have defined a workflow which include 3 Process variable. When I want to start it through DFC API, I didn't how to put a string, int ,bool etc., into the process variable.

The DFC Version i use is DFC 6.0 SP1.

Any one have an idea. help, please .....

Best Answer

  • tarh33l
    edited October 8, 2008 #2 Answer ✓
    Options

    I've recently run into this issue myself. The trick is that Process Variables cannot be changed once the workflow is running (in fact, in the DfWorkflowEx class, there's a method that's supposed to throw an exception if you attempt to set variables on a workflow that's not dormant. Unfortunately, that method isn't called so you think everything's set when in fact, they're not). To ensure that your variables are set correctly, first init the workflow (this assumes you want to set the variables at the start of the workflow, not in the middle):

    IDfId NewWorkflowId = workflowBuilder.initWorkflow();

    then ,set the Process Variables (assumes you get a handle to the workflow first):

    <span class="jive-thread-reply-body-container">wfe.setPrimitiveObjectValue("Name", "Freddy")

    then, run the workflow:

    IDfId NewWorkflowId2 = workflowBuilder.runWorkflow();

    That should be it!

    - Terence

Answers

  • mszurap
    edited October 7, 2008 #3
    Options

    Process variables can be used with Process Builder, not with Workflow Editor which functionality is part of DFC. So what you are searching for (BPM JavaDocs) is located in your Content Server machine: $DOCUMENTUM_SHARED/help/bpm.

    There is DfWorkflowEx which contains the methods to add primitive values (and structured data types) to your workflow instance.

    Cheers,

    Mike

  • freddybrito
    edited October 7, 2008 #4
    Options

    Hi, i try to set primitive values but system dont take the changes. Any Help? , I put my code here.

    DfId idw = new DfId("4d01e24080000686"); // Any running workflow.
    IDfWorkflow wf = (IDfWorkflow) session.getObject(idw);
    IDfWorkflowEx wfe = (IDfWorkflowEx) wf;
    wfe.getPrimitiveVariableValue("Name"); // Returns -&gt; Blank String (Default Value)
    wfe.setPrimitiveObjectValue("Name", "Freddy") //It looks like fine
    wfe.getPrimitiveVariableValue("Name"); //Returns -&gt; Diego

    Them when i go to WebTop the Process Variables don´t take change.

  • tarh33l
    edited October 8, 2008 #5 Answer ✓
    Options

    I've recently run into this issue myself. The trick is that Process Variables cannot be changed once the workflow is running (in fact, in the DfWorkflowEx class, there's a method that's supposed to throw an exception if you attempt to set variables on a workflow that's not dormant. Unfortunately, that method isn't called so you think everything's set when in fact, they're not). To ensure that your variables are set correctly, first init the workflow (this assumes you want to set the variables at the start of the workflow, not in the middle):

    IDfId NewWorkflowId = workflowBuilder.initWorkflow();

    then ,set the Process Variables (assumes you get a handle to the workflow first):

    <span class="jive-thread-reply-body-container">wfe.setPrimitiveObjectValue("Name", "Freddy")

    then, run the workflow:

    IDfId NewWorkflowId2 = workflowBuilder.runWorkflow();

    That should be it!

    - Terence

  • freddybrito
    edited October 10, 2008 #6
    Options

    My final code, as example, it will be helpful:

    IDfWorkflowBuilder workflowBuilder = session.newWorkflowBuilder(id);

    IDfId initWf = workflowBuilder.initWorkflow();

    IDfWorkflowEx setVariables = (IDfWorkflowEx) session.getObject(initWf);

    setVariables.setPrimitiveObjectValue("VARNAME1",value1);

    setVariables.setPrimitiveObjectValue("VARNAME2",value2);

    setVariables.setPrimitiveObjectValue("VARNAME3",value3);

    IDfId idWf = workflowBuilder.runWorkflow();

    return idWf;

    Thank's, for all support !!