Modify Workflow Definition XML via Web Services

Justin "JET" Turner's Avatar

Justin "JET" Turner

10 Jun, 2013 07:57 PM


We have a fairly generic workflow definition we use for each site. The primary difference from one site to another is the workflow name (named after the department for easy recognition in emails), and the default-group attribute of an unordered step (the group of editors for that site).

I thought that maybe I could just read the XML, do a quick find and replace and then set the XML back, this throws the following error:

PHP Fatal error:  Uncaught SoapFault exception: [soapenv:Server.generalException] Validation error: cvc-complex-type.2.4.b: The content of element 'ns1:asset' is not complete. One of '{"":workflowConfiguration, "":feedBlock, "":indexBlock, "":textBlock, "":xhtmlDataDefinitionBlock, "":xmlBlock, "":file, "":folder, "":page, "":reference, "":xsltFormat, "":scriptFormat, " in [path]\new-site.php on line 327

I've built the following function to make the changes to our workflows, but I get basically the same error as above even when just trying to change the name.

function modifyWorkflowDefinition($item, $newName, $changeUsers)
    global $auth, $client, $siteName, $groupName;
    $identifier = array
        'path' => array(
            path => $item,
            siteName => $siteName),
        'type' => 'workflowdefinition'
    $readParams = array ('authentication' => $auth, 'identifier' => $identifier);
    $reply = $client->read($readParams);
    echo "<pre>";
    echo "</pre>";
    $asset = $reply->readReturn->asset->workflowDefinition;
    $asset->name = $newName;
        $xml = $asset->xml;
        echo $xml."<br>";
        $xml = str_replace('department-name',$siteName,$xml);
        $xml = str_replace('default-group="Administrators"','default-group="'.$groupName.'"',$xml);
        $asset->xml = $xml;
        echo $xml;
    $editParams = array('authentication' => $auth, 'asset' => array('workflowdefinition' => $asset));
    $reply = $client->edit($editParams);
        echo " Success<br>";
        echo " Fail<br>";
  1. 1 Posted by Ryan Griffith on 10 Jun, 2013 08:16 PM

    Ryan Griffith's Avatar

    Hi Justin,

    I noticed the following line uses workflowdefinition as opposed to workflowDefinition.

    $editParams = array('authentication' => $auth, 'asset' => array('workflowdefinition' => $asset));

    Try tweaking this to the following and let me know if this fixes things or produces an error:

    $editParams = array('authentication' => $auth, 'asset' => array('workflowDefinition' => $asset));

    Please let me know if you have any questions.


  2. 2 Posted by Justin &quot;JE... on 10 Jun, 2013 08:24 PM

    Justin &quot;JET&quot; Turner's Avatar

    That got rid of the error, I must have copied the 'type' from the identifier instead of the variable name from the print_r.

    The code changed the group, but didn't actually rename the item inside of cascade.
    I tried adding $asset->path = 'UNG/'.$newName; but it still isn't performing the rename. Is there something else that needs to be done to perform a rename? Maybe call the move function?

  3. 3 Posted by Justin &quot;JE... on 10 Jun, 2013 08:33 PM

    Justin &quot;JET&quot; Turner's Avatar

    Yep, the move command did the trick.

  4. Justin "JET" Turner closed this discussion on 10 Jun, 2013 08:33 PM.

  5. Ryan Griffith re-opened this discussion on 10 Jun, 2013 08:38 PM

  6. 4 Posted by Ryan Griffith on 10 Jun, 2013 08:38 PM

    Ryan Griffith's Avatar

    Glad to hear that did the trick. Correct, the move/rename operation would be used to change the Asset's path and name.

    Please let me know if you have any questions.


  7. Justin "JET" Turner closed this discussion on 11 Jun, 2013 11:42 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac