It's all about the answers!

Ask a question

How to set preconditions programatically ?

Amit Ghatge (1910) | asked Jun 02 '19, 9:11 a.m.
edited Jun 03 '19, 2:13 a.m. by Ralph Schoon (63.3k33646)


I am trying to set preconditions & follow up actions programatically using plain java API. Manually what we do is create a new configuration and then for save operation we set some preconditions & follow up actions. What i want to achieve is to create a new configuration for save work item operation (using plain java api). So do you guys know how can i achieve it ? I couldn't find any java documentation/API to create a new configuration for save work item operation


Accepted answer

permanent link
Ralph Schoon (63.3k33646) | answered Jun 03 '19, 2:35 a.m.

Amit, there is no documented API for this. You basically have to manipulate the process configuration XML file and save it.

This is an example how this can be done. Note that this is potentially dangerous.
        IProcessClientService processClient = (IProcessClientService) teamRepository

    URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
    IProjectArea projectArea = (IProjectArea) processClient
            .findProcessArea(uri, null, monitor);
    if (projectArea == null) {
        System.out.println("Project area not found.");
        return false;

    projectArea = (IProjectArea) projectArea.getWorkingCopy();
    // Set to share process
    // setProcessToSahred(projectArea);
    // setShareProcess(thisProjectArea, projectAreaSharingItsProcess)

    Map<String, IContent> pd = projectArea.getProcessData();

    IContent content = (IContent) pd
    if (content != null) {
        String processConfig = createStringFromContent(teamRepository,
                content, monitor);
        String newProcessConfig = processConfig.replace(
                "this-is-a-fake-url", "http://localhost/index.html");
        IContent newContent = createContentFromString(teamRepository,
                newProcessConfig, monitor);
        pd.put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent);
        IProcessItemService processItemService = (IProcessItemService) teamRepository
                .getClientLibrary(IProcessItemService.class);, monitor);
Amit Ghatge selected this answer as the correct answer

Amit Ghatge commented Jun 03 '19, 4:46 a.m.

Thanks Ralph ! It seems manipulating the process XML is the only way to achieve it.  

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.