Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We are using Nintex workflow, but are struggling with how to incorporate this into a proper application lifecycle. In the best case, we'd like workflows to be packaged and this package to be deployed between environments. We don't have automated builds / deployments and stuff like that; but manually exporting and importing again isn't really a good solution when you ask me.

So I was wondering whether there is someone with experience on this matter who could maybe share some tips and tricks. We're looking for ways to deploy workflows as well as UDA's and/or constants. WSP is an option, scripted Powershell could be an option as well; bring it on :)

share|improve this question

closed as off-topic by RJ Cuthbertson, PirateEric, Benny Skogberg, Robert Lindgren, Daniel Ziga Oct 17 '13 at 11:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer 1

OK I haven't actually done this, but we have deployed Nintex Workflow in our project. After reading through you need to do the following.

  1. Have a SharePoint Module with the exported .nwf file included.
  2. Have a site feature that includes this module.
  3. Then in the feature Activating event

public override void FeatureActivated(SPFeatureReceiverProperties properties){

    SPSite site = properties.Feature.Parent as SPSite;
    var targetWeb = site.RootWeb;
    //Read in the workflow package file into a byte array
    byte[] nwfFile = GetWorkflowNWF(properties.Feature.Definition);

    //Construct Nintex Web service Url
    string webServiceUrl = targetWeb.Url;


     if (!webServiceUrl.EndsWith("/")) webServiceUrl += "/";
            webServiceUrl += "_vti_bin/nintexworkflow/workflow.asmx";  

//Publishing Nintex workflows does not work over https
   webServiceUrl = webServiceUrl.Replace("https", "http");


  // Call the Nintex web service to publish/save the workflow
  NintexWorkflowWS.NintexWorkflowWS service = new NintexWorkflowWS.NintexWorkflowWS();
  service.Url = webServiceUrl;
  service.Credentials = GetRunTimeCredentials(targetWeb);
  bool success = service.PublishFromNWF(nwfFile, NameOfListToAssignTo,  DestinationWorkflowName, true);
}


//NintexCredentialConstantName is something set in Central Admin -> Nintex Workflow Management -> Manage workflow constants. 
  private NetworkCredential GetRunTimeCredentials(SPWeb web)
        {
            Nintex.Workflow.WorkflowConstantCollection constants = Nintex.Workflow.WorkflowConstantCollection.GetWorkflowConstants(web.ID, web.Site.ID);
            Nintex.Workflow.CredentialValue credValue = constants.GetCredential([NintexCredentialConstantName]);
            if (credValue == null)
                throw new ArgumentOutOfRangeException("nintexCredentialConstantName", string.Format("Could not find a workflow constant called '{0}'.", [NintexCredentialConstantName]));

            return (credValue.Username.IndexOf("\\") > 0) ?
                new NetworkCredential(credValue.Username.Substring(credValue.Username.IndexOf("\\") + 1), credValue.Password, credValue.Username.Substring(0, credValue.Username.IndexOf("\\"))) :
                new NetworkCredential(credValue.Username, credValue.Password);
        }

        private byte[] GetWorkflowNWF(SPFeatureDefinition feature)
        {
            using (Stream nwfFile = feature.GetFile(Constants.pathToNWF))
            {
                byte[] buffer = new byte[1024];
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    int read;
                    while ((read = nwfFile.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        memoryStream.Write(buffer, 0, read);
                    }

                    return memoryStream.ToArray();
                }
            }
        }
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.