How to approve or reject SharePoint workflow using Nintex workflow

To approve or reject a SharePoint Workflow from a Nintex Workflow is very easy. There is a web service exposed from SharePoint which is Workflow.asmx, you can access it at

http:// server /_vti_bin/workflow.asmx

Now the method that we will be using to action our SharePoint workflow is AlterToDo. This method takes the following arguments:

  • Item (The URL location of an item on which a workflow is being run)
  • todoId (Unique identifier of the assigned task)
  • todoListId (Globally unique identifier (GUID) of the assigned task list containing the task)
  • taskData (Task data for conversion into a hash table)

Okay so back to Nintex now.

Step 1: Add a call web service workflow action and configure it.

Step 3: Add URL of workflow.asmx web service in the URL field, specify username and password and click refresh to update list of available methods in the Web Service

Step 3: Select SOAP Editor in editor mode, this is necessary as you will be adding some xml in TaskData parameter and select SOAP builder mode seems to html encode < > signs which results in error

Step 4: Specify item, todoId, todoListId and paste the following xml in tag.

<my:myFields xmlns:my=”http://schemas.microsoft.com/office/infopath/2003/myXSD&#8221; >

<my:TaskStatus>Approved</my:TaskStatus>

<my:Status>Completed</my:Status>

<my:PercentComplete>1.00000000000000</my:PercentComplete>

<my:Completed>1</my:Completed>

</my:myFields>

Your configuration should look something like this

Calling Workflow.asmx using Nintex workflows

Try some fixed values first for testing purposes and click run and then replace them.

I hope you find this post useful. Thanks for reading.

About these ads

About Khurram Punjwani

Khurram Punjwani is a passionate .NET / SharePoint Consultant who specializes in delivering extensible solutions using agile methodologies. View all posts by Khurram Punjwani

11 responses to “How to approve or reject SharePoint workflow using Nintex workflow

  • Hammad Haneef Pasha

    hiee Khurram,
    I have an issue with Nintex, My workflows are hanging in the system. If the Workflow task is left for two days or more in Not Started state and then approved, it goes in “In Progress” for ever. Can you help me in this. What could be the reasons of this ?

    • Khurram Punjwani

      Hi Hammad,

      Thank you for commenting on my blog, Sure, I’ll will try my best to help you out. I saw the beautiful exception message you’ve posted on Nintex Connect :p. The following excerpt from your exception message seems interesting

      *Access Denied for /contoso/_layouts/IniWrkflIP.aspx?List={b713a4ad-747e-4980-ad1c-c420d3f588b7}&ID=1&TemplateID={3cf9d212-c83d-4486-9fce-ee8d00efacbc}&Source=blah

      *Check out this blog, it seems this guy had the same issue. I hope this will help you out. Keep me posted.

  • SV

    Khurram,

    Similar to the one above, can we reassign a task using web services?

    • Khurram Punjwani

      Thanks for reading SV. If you have a task list associated with a workflow and want to update task associated with an instance then try this solution (http://go4answers.webhost4life.com/Example/reassgin-task-request-change-altertodo-48607.aspx), you will have to specify tag.

      If have you don’t have any workflow associated with a task list then you can try list.asmx webservice to update list items, check this out for more details (http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(v=office.12).aspx)

      • SV

        Thanks for the response Khurram.

        I tried the solution you have described above, but it did not make any change. http://go4answers.webhost4life.com/Example/reassgin-task-request-change-altertodo-48607.aspx
        There were no errors too.
        Here is what I did.
        String SiteUrl = SPContext.Current.Web.Url + “/”;
        WorkflowService.Workflow ws = new WorkflowService.Workflow();
        ws.Url = SiteUrl + “/_vti_bin/workflow.asmx”;
        ws.Credentials = CredentialCache.DefaultCredentials;

        StringBuilder xmlBuilder = new StringBuilder();
        //xmlBuilder.Append(“”);
        xmlBuilder.AppendFormat(“”, “http://schemas.microsoft.com/office/infopath/2003/myXSD”);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.AppendFormat(“{0}”, user.Name);
        xmlBuilder.AppendFormat(“{0}”, user.LoginName);
        xmlBuilder.AppendFormat(“{0}”, “User”);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.AppendFormat(“{0}”, Description);
        xmlBuilder.AppendFormat(“2012-11-21 11:21:00″);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.Append(“”);
        xmlBuilder.AppendFormat(“{0}”, Status);
        xmlBuilder.Append(“”);
        //xmlBuilder.Append(“”);
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xmlBuilder.ToString());

        //XmlNode todosForItem = ws.GetTemplatesForItem(itemUrl);
        SPList tasksList = SPContext.Current.Web.Lists[GetConfigValueByKey(“AccessITTasks”)];

        XmlNode node = ws.AlterToDo(SiteUrl + itemUrl, taskItem.ID, new Guid(tasksList.ID.ToString()), doc.DocumentElement);

      • Khurram Punjwani

        SV, is your task list associated with any workflow? and are you planning to action this workflow via the web service or do you just have a task list and update the assigned to field via web service?

      • SV

        I have a task list associated with a workflow which is assocaited to a content type. Yes, I will to reassign a task using web service.

  • SV

    Also, in this case what is ?

  • Dan Stoll (@_danstoll)

    You can delegate tasks using the Nintex webservice /_vti_bin/nintexworkflow/workflow.asmx

  • GUARAV

    How to include ‘Comments’ with Approve/reject request ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 140 other followers

%d bloggers like this: