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
  • Hi Dkahraman

    Yes, it is possible to have different workflow for different documents. You can create different workflows and can have action submit to Workflow from item which will open a form where user will select the workflow and you need to instantiate the workflow dynamically. Instead of action, you can also run the method on selection of document classification to achieve this.

  • is there any sample code? I've tried something else but it's not working.

  • オフライン in reply to dkahraman

    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;
    }

Reply
  • オフライン in reply to dkahraman

    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;
    }

Children
No Data