How to set primitive values in IDfWorkflowEx???

freddybrito
edited October 10, 2008 in Documentum #1

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 -> Blank String (Default Value)
wfe.setPrimitiveObjectValue("Name", "Freddy") //It looks like fine
wfe.getPrimitiveVariableValue("Name"); //Returns -> Diego

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

Comments

  • freddybrito
    edited October 8, 2008 #2

    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):

    wfe.setPrimitiveObjectValue("Name", "Freddy")

    then, run the workflow:

    IDfId NewWorkflowId2 = workflowBuilder.runWorkflow();

    That should be it!

    • Terence

  • freddybrito
    edited October 10, 2008 #3

    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 !!