none
How to approve nintex workflow flexi task from sharepoint object model by calling nintex webservice RRS feed

  • Question

  • I am trying to approve nintex worklfow flexi task by using the below code,and its working perfectly in Visual Studio 2012 Console application but when I am trying to incorporate the same code Sharepoint 2013 visual webpart its not working. I understand the problem with the logged in user credential,in order to call the webservice with system account permission I have used the RunWithElevatedPrivileges code and since this account is not the approver, so does not have any pending task.Then if I try to run the code with the logged in user(by commenting RunWithElevatedPrivileges code) permission who is the actual approver, in this case logged in user getting 401 unauthorized access to webservice error. My basic objective is to approve the nintex workflow flexi task from sharepoint visual webpart. How can do this any help would be much appreciated.

    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        try
            {
        using(SPSite mySPSiteObject=new SPSite(SPContext.Current.Site.Url))
        {
            using(SPWeb myWeb=mySPSiteObject.OpenWeb())
            {
    
                ProcessTaskResponseResult? result = null;                 
               NintexApprovalService.NintexWorkflowWS objNintextClient = new NintexApprovalService.NintexWorkflowWS();              
    
               objNintextClient.UseDefaultCredentials = true;
               NintexApprovalService.UserTask[] userTask =objNintextClient.GetRunningWorkflowTasksForCurrentUser(itemUrl);    //This webmethod will give array of assigned tasks.
              foreach (NintexApprovalService.UserTask objTask in userTask)
                    {
                        int taskID = objTask.SharePointTaskId;
                        result = CallProcessTaskResponse(taskID);
                    } 
            }
        }
             }
    
    catch(Exception e)
    {
     Logger.write(e.message + "--" + e.stackTrace); 
    }    
     });
    Monday, May 18, 2015 11:27 AM

All replies

  • Hi Murali,

    Is that you got any solution to this task.  I am also stuck in this palce, it's not getting any task if i use 

    objNintextClient.UseDefaultCredentials = true;

    But if I use objNintextClient.Credentials = new System.Net.NetworkCredential("", "", "") this it will get the task

    Please help me to achieve the same in another way.

    Thanks & Regards,

    Dhinesh Kumar J.



    Dhinesh Kumar,

    Friday, February 19, 2016 7:22 AM
  • Hi Dhinesh, 

    Please avoid using Webservice instance to approve the task or any operations which you try to accomplish, i would suggest you to use the Server Side Code Based on nintex dll "Nintextworkflow.dll".

    That approach really helped me, so no problem.



    Muralidharan...!!

    Friday, February 19, 2016 8:10 AM
  • Hi Murali,

    If you could give me the code snippet here it would be really helpful for me to proceed further. I was in bit confusion how to achieve nintex workflow.dll to project kind of things. 

    Thanks & Regards,

    Dhinesh Kumar J.


    Dhinesh Kumar,

    Friday, February 19, 2016 9:40 AM