0

I'm trying to make a SharePoint 2013 app which kicks off a workflow. Already googled and tried samples, but keep getting this error :

0x800a139e - JavaScript runtime error: The property or field 'PropertyDefinitions' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Any help would be appreciated..

UPDATE Tried code from @wjervis, the PropertyDefinitions error is gone. But still can't start workflow. The subscription service and subscription loaded successfully, but failed when starting workflow. The error message is "invalid request" and stack trace contains "undefined".

<SharePoint:ScriptLink ID="ScriptLink1" Name="MicrosoftAjax.js" runat="server" Defer="False" Localizable="false"/>
<SharePoint:ScriptLink ID="ScriptLink2" Name="SP.core.js" runat="server" Defer="False" Localizable="false"/>
<SharePoint:ScriptLink ID="ScriptLink3" Name="SP.js" runat="server" Defer="false" Localizable="false"/>
<SharePoint:ScriptLink ID="ScriptLink4" Name="SP.runtime.js" runat="server" Defer="false" Localizable="false"/>
<SharePoint:ScriptLink ID="ScriptLink5" Name="SP.workflowservices.js" runat="server" Defer="true" Localizable="false"/>

function StartWorkflow(subId, itemId) {
var clientContext;
var factory;
var appContextSite;
var hostweb, hostcontext;

clientContext = new SP.ClientContext(appweburl);
factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
clientContext.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(clientContext, hostweburl);
hostweb = appContextSite.get_web();
clientContext.load(hostweb);

var wfServiceManager = SP.WorkflowServices.WorkflowServicesManager.newObject(clientContext, hostweb);
var wfDeployService = wfServiceManager.getWorkflowDeploymentService();
var subService = wfServiceManager.getWorkflowSubscriptionService();

clientContext.load(subService);
clientContext.executeQueryAsync(function () {
    console.log("Subscription Service was loaded.  Attempting to get workflow subscription.");
    var subscription = subService.getSubscription(subId);
    console.log("Subscription was loaded, attempting to start workflow.");
    if (itemId != null && itemId != '' && itemId != undefined) {
        wfServiceManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, new Object());
    } else {
        console.log("Item Id was not provided.  Ending function.");
        return;
    }

    clientContext.executeQueryAsync(function () {
        console.log("Successfully started workflow.");
    }, function (sender, args) {
        console.log("Failed to start the workflow.");
        console.log("Error: " + args.get_message() + "\n" + args.get_stackTrace());
    });
}, function (sender, args) {
    console.log("Failed to load the subscription.");
    console.log("Error: " + args.get_message() + "\n" + args.get_stackTrace());
});

}

  • Does your workflow have an input form? That form data is only needed if so. – wjervis Aug 6 '14 at 11:01
  • Does this answer resolve your troubles? sharepoint.stackexchange.com/questions/109166/… – wjervis Aug 6 '14 at 11:12
  • Tried your code, the subscription service and subscription loaded successfully, but failed when starting workflow. The error is "invalid request" and the stack trace only contains "undefined". Any ideas ? – dennyw Aug 7 '14 at 2:03
  • I would say try without the factory, but seeing that you were able to load the subscription, I don't see why that would cause any issues. – wjervis Aug 7 '14 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.