How to multiple DCOs

Hi,

is it possible to have multiple DCOs? Because we want to have a different workflow for different documents.

How to do this?

thanks,

Parents Reply Children
  • Hi Dkahraman

    I have not tested but you can try the below

    Prerequisites:

    Create Multiple Workflows and add to Document item type and ensure that Assignments are added in Workflows

    Create Custom Form name : Workflow_Form with Document Number, Drop Down list for selecting Workflow, Submit Button and Close button

    Create Action named Submit Workflow --> Item, Client, None and Method 

    Create Method 1: Name:  Submit_workflow and add to action created above.

    //debugger;
    var inn = this.getInnovator();
    var isLocked = this.getLockStatus();
    if (isLocked !== 0)
    {
    alert("Unlock the document to start workflow");
    return;
    }
    //Check whether the item already associated to any other workflow
    var wfProcess = inn.newItem("Workflow Process","get");
    wfProcess.setProperty("name",this.getProperty("item_number"));
    wfProcess = wfProcess.apply();
    var wfCount = wfProcess.getItemCount();
    if ( wfCount !== 0)
    {
    alert("Workflow Process already exists for this document");
    return;
    }

    //load workflow form
    var formItem = new Item("Form", "get");
    formItem.setAttribute("select", "id");
    formItem.setProperty("name", "Workflow_Form");
    formItem = formItem.apply();
    if( formItem.isError())
    {
    alert("Error loading form");
    return;
    }

    // Set Parameters
    var param = top.aras.newObject();
    param.title = "Select Workflow";
    param.formId = formItem.getItemByIndex(0).getID();
    param.item = this;
    param.aras = top.aras;
    options= {
    dialogWidth: 700,
    dialogHeight: 200,
    resizable: 'no'
    };
    var res = top.aras.modalDialogHelper.show('DefaultModal', window, param, options, 'ShowFormAsADialog.html');

    In Workflow_Form, onform populated form event, add the below method to load the drop down list of workflow

    Create Method 2 : Add_DropDownList_Workflow (Ensure that your form has workflow_dropdown field

    var inn = document.thisItem.getInnovator();
    var workflowField = getFieldByName("workflow_dropdown").getElementsByTagName("select")[0];
    // clear List
    var listCount = workflowField.options.length;
    for (var i = 0; i < listCount; i++) {
    workflowField.remove(workflowField.options[i]);
    }
    workflowField.options[0] = new Option("","");
    listCount = 1;
    // Workflow associated with Document
    var item = inn.newItem("ItemType","get");
    item.setProperty("name","Document");
    item = item.apply();
    if(item.isError())
    {
    top.aras.AlertError(item.getErrorDetail());
    return;
    }
    var workflowList= inn.newItem("Allowed Workflow","get");
    workflowList.setProperty("source_id",item.getID());
    workflowList = workflowList.apply();
    if(workflowList.isError())
    {
    alert("Cannot fetch Workflow for Document");
    return;
    }
    var count = workflowList.getItemCount();
    if (count === 0)
    {
    alert("No allowed Workflow linked with Document");
    return;
    }
    for (var i = 0; i < count; i++)
    {
    var listVal = workflowList.getItemByIndex(i);
    var workflow = listVal.getRelatedItem();
    var workflowName = workflow.getProperty("name");
    workflowField.options[listCount] = new Option(workflowName,workflowName);
    listCount++;
    }
    return;

    In Workflow_Form,  Submit button, Create On Click field event, add the below method

    Create Method 3: Instantiate_Workflow

    //debugger;
    var inn = document.thisItem.getInnovator();
    document.getElementById("MainDataForm").submit.disabled = true;
    var workflowField = getFieldByName("workflow_dropdown").getElementsByTagName("select")[0];
    var workflowName = workflowField.options[workflowField.selectedIndex].value;

    //Document for workflow
    var documentNo = document.forms[0].item_number.value;

    var documents = inn.newItem("Document","get");
    documents.setProperty("item_number",documentNo);
    documents = documents.apply();
    if(documents.isError())
    {
    alert(documents.getErrorDetail());
    document.getElementById("MainDataForm").submit.disabled = false;
    return;
    }
    var documentID = documents.getID();

    var workflowItem = inn.newItem("Workflow Map","get");
    workflowItem.setProperty("name",workflowName);
    workflowItem = workflowItem.apply();
    if(workflowItem.isError())
    {
    alert(workflowItem.getErrorDetail());
    document.getElementById("MainDataForm").submit.disabled = false;
    return;
    }
    var mapId = workflowItem.getID();
    var workflow = documents.instantiateWorkflow(map_ID);
    if (workflow.isError())
    {
    alert("Error starting workflow");
    document.getElementById("MainDataForm").submit.disabled = false;
    return;
    }
    else
    {
    workflow.apply("startWorkflow");
    alert("Workflow Started Successfully.");
    closeWindow();
    return;
    }

  • Hi Dkahraman

    I cannot able to share the method here as the size exceeds the allowed limit and it is marked as SPAM.

  • we wrote something like this but there is no active state within the workflow process and no assignment task is created.

    ....

    Item wflMap = inn.getItemByKeyedName("Workflow Map", wflMapName);

    Item wfl = this.instantiateWorkflow(wflMap.geID());

    wfl.promote("Active", "no comment");

    return this;

    ....