SharePoint 2013 Workflows. Part 2/3: custom ASP.Net task form

Want create site? Find Free WordPress Themes and plugins.

Hi!

This is the second post of the series related to SPD 2013 Workflows. In this post I will show you how to implement custom ASP.Net task form and embed it into your workflow. Some parts of this task are straightforward; However, there are several pitfalls and changes from SP2010.

This series consists of 3 parts:

1. Creating extremely simple workflow with the default task form. This part is for very beginners only and if you know how to create simple SPD workflow you can skip this part without any risks to not to understand the following parts, but if you are a beginner, it is the right place to start!

2. Implementing custom ASP.NET task form and embeding it to a workflow (this part). In this part you could find information how to create custom task forms. Also in this part you can find the answer on the question “How to complete a task or change an assignee if old SP2010 methods don’t work anymore?”.

3. Tips and hints of custom ASP.NET task forms creation. In this part you can find information how to implement reusable parts of task forms, how to force SP controls work as expected after changing context, how to create analogue of the Request Changes behavior which was built-in in SP2010, but should be implemented by yourself in SP2013 and some other techniques!

Let’s get started!


Steps overview:

  1. Step 1. Creating custom ASP.NET task form.
  2. Step 2. Making task activity to use the new custom task form.
  3. Step 3. Adding form logic for showing and completing a task.
  4. Conclusion.

Step 1. Creating custom ASP.NET task form.

1. Create new SharePoint 2013 empty project.

For that open Visual Studio 2012 and create a new project.

Creating new project in Visual Studio

Select the “SharePoint 2013 – Empty Project” template.

note: If you can’t see this template then, most likely, you didn’t install Microsoft Office Developer Tools for Visual Studio 2012. These tools are necessary for the most of the development tasks for SharePoint in Visual Studio.

Selecting SharePoint 2013 - Empty Project template 

Enter the URL of your SP site and select “Deploy as a farm solution”.

Entering URL of our farm

2. Add SharePoint “Layouts” Mapped Folder in your project.

For that you could right-click on your project, select “Add” and then “SharePoint ‘Layouts’ Mapped Folder”.

Adding SharePoint Layouts Mapped Folder to the project

3. Add new Application page in your project.

For that, you should right click on the folder with the name of your project in the Layouts. Select “Add” \ “New Item…”, then select “Application Page (Farm Solution only)” and fill in name for our first ASP.NET task form (“MyCustomTaskForm.aspx” in my example).

Adding new Item to the Layouts folder

Adding new Application page which will be our custom task form later

Visual Studio will create a default Application Page which will be similar to this one shown on the screenshot below. Have a look at the text inside the “asp:Content” with IDs “PageTitle” and “PageTitleInTitleArea”. Where are strings “Application Page” and “My Application Page”.Content of the default application page

Results of the first step: We have just created a simple ASP.NET page. Now, you can test, whether you could see it in your browser. For this, you could press CTRL-F5 in VS to deploy your project and enter path to your form (“YourSiteUrl/_layouts/15/Custom2013TaskForms/MyCustomTaskForm.aspx”) in your browser. You should see your first form (for a while it contains only from the Title “My Application Page”).

Checking whether default application page was deployed sucessfully


Step 2. Making task activity to use the new custom task form.

During this step we have to create a new content type which is derived from the “Workflow Task (SharePoint 2013)” one, add it to Workflow Tasks list, change edit form of our content type to the new one created by us in the first step. After that we should change task content type to ours in the workflow task action.

This part seems to be done very easily; however, there are some pitfalls where I spent a lot of time to understand how to do it correctly.

Pitfall: There is an issue in content types which use inheritance. It is impossible to change forms (New, Display and Edit) for content types which are derived from others. When you change link to their forms using SPD or the special tags in declarative XML definition it just doesn’t work. SP doesn’t show you any error messages, you just see standard forms instead of the custom ones. However, as you remember, we have to derive our task content type from “Workflow Task (SharePoint 2013)” to be able to customize it. So, we come to a paradoxical situation. On the one hand we should create new inherited task content type to be able to customize it, but on the other hand it is impossible to use custom forms for the content type if it is inherited.

Workaround: Fortunately, we can change forms of derived content type using SP Object model (this way works correctly for the derived content types).

1. Create a new Content Type derived from the “Workflow Task (SharePoint 2013)”.

For that open your site collection in SPD, select “Content Types” in the “Site Objects” and press the Content Type button in the ribbon. After that fill in name and description of the new custom task content type.

Important: Select parent content type “Workflow Task (SharePoint 2013)” which is located in the “List Content Types” group.

Creating new workflow 2013 task content type

 

2. Add new content type to the list of content types for the “Workflow Tasks” list.

Important: This is a mandatory step to be able to use custom task content type. If you don’t add it, you will get strange error messages when WF tries to assign a task.

For that you can open this list in SPD.

Opening workflow task list

Make sure that management of content type is enabled for this list (checkbox A is ticked). Press the “Add…” button, select new task content type and press OK.

Adding new content type to the workflow task list (for using custom task form later)

After that you should see new content type in the list of Content Types for Workflow Task list.

Checking new content type in the task list

 

3. Change edit form of our task content type to the form we have created in the first part.

One of the possible ways to do this is to use Feature Event Receiver. For that we should add a feature and an Event Receiver.

Adding new feature to the SharePoint 2013 projectAdding feature event receiver

VS creates default Event Receiver for us. We have to uncomment FeatureActivated method and add our code which will change Edit form for our content type inside of it.

Piece of code for copy-paste:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {        
        SPWeb web = properties.Feature.Parent as SPWeb; 
        SPContentType ct = web.ContentTypes["MyTaskContentType"];
        ct.EditFormUrl = "_layouts/15/Custom2013TaskForms/MyCustomTaskForm.aspx";
        ct.Update(true);
    }

Our FeatureActivated method of the Event Receiver should look as follows in VS:

Code of the Event Receiver

4. Change Content type of our task activity in Workflow from the default “Workflow Task (SharePoint 2013)” to our new “MyTaskContentType” one.

For that we should open our “Request supplies” workflow (which was created in the previous part of this series) in SPD.

Opening our workflowPressing the edit workflow link

Open task process for editing (click on the assignee).

Opening workflow task activity

 

Change task content type field in the Outcome Options section to our custom task content type (MyTaskContentType).

Changing workflow task content type

Save changed workflow and publish it by pressing buttons in the ribbon.

Saving changes and publishing the workflow

 

5. Deploy our project using VS and make sure that Edit form for our content type is changed.

For that, press CTRL-F5 in VS (our project deploys and Event Receiver changes edit form for our content type).

To check whether edit form is changed, we could press F5 in SPD to get the latest information from the server, and select our content type.

Opening custom workflow task content type

We should see that now it uses our ASP.NET form, which was created on the first step.

Checking custom workflow task content type edit form

6. Check whether default task form has changed to our new one.

To check it we should start new instance of the “Request supplies” workflow and edit the “Provide office supplies” task.

For that open list “Office supplies requests” in a browser, select an item (or create a new one) and start workflow on it by clicking “…” \ “Workflows” \ “Request supplies”.

Opening list of available workflowsStarting new workflow instance on the item

 

Open list of tasks for WF which we have just started. You can do this in two different ways:

a) click “…” \ “Workflows” and select “Request supplies” from the list of running workflows. Make sure that this is a new version of workflow by looking on its date. If you can’t see the new WF, wait a bit and periodically refresh your browser (F5). Starting of the new WF usually takes not more than half a minute.

Opening list of running workflows

 

Checking running workflow on the list item

 

b)  Or alternatively, just click on the status link for the Request supplies workflow. However, in this case you should wait a bit and refresh your browser (F5) to make sure, that this link is related to the WF you have just started and not to WF, which was started some time ago.

Checking workflow status

 

You should see a new task “Provide office supplies”. Press “V” \ “Edit” and our ASP.NET task form should appear (as you remember for the moment it consist from the Title “My Application Page” only).

Editing task (opening custom workflow task form)

Checking whether we can see custom task form

 

Results of this step: We have created a custom task content type which uses our custom ASP.NET form for editing information. Also, now, our WF uses this content type for tasks, so when we select “Edit Item” on a task we can see our custom ASP.NET task form (which is not ready to show all the information yet).


Step 3. Adding form logic for showing and completing a task.

The last step is to add controls to our custom ASP.NET task form and make them interact with the workflow.

Pitfall: Ways of interacting with WF which we could use in SP2010 don’t work with SP2013 WFs anymore. Also, today (March 2013) there is the lack of documentation for ways of interacting with the Workflow Manager and it seems nobody (except Workflow Manager development team from Microsoft) knows how to work with it.

Workaround: Tasks activities in its internals use subscribing on item change event to make conclusion if task is completed, so we can change task fields directly and task activity will perform check immediately after that. For instance if we want to reassign our task, we could simply change the “Assigned To” field of the task item.

note: if you want to have a look at internals (XAML) of some activities yourself, you can open table [dbo.Activities] which is located in [WFResourceManagementDB] using SQL Server Management Studio.

1. Open our ASPX form page (MyCustomTaskForm.aspx) in VS and add layout and controls to it.

For that replace all “asp:Content” elements of MyCustomTaskForm.aspx file (don’t touch rows starting with “<%@”) with the following:

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <style type="text/css">
        .taskInfo {
            width: 500px;
            border: black 2px solid;
            border-collapse: collapse;
        }

        .taskInfo > tbody > tr > td {
            border: black 1px solid;
        }

        .taskInfo td.buttons {
            border-bottom-width: 2px;
        }

        .header {
            color: white;
            background-color: #0071C6;
            font-size: 20px;
            text-align: center;
        }

        .buttons table {
            display: inline;
            vertical-align: bottom;
            width: 20px;
        }

        .field {
            width: 100px;
            background-color: #DDDDDD;
        }

        .fieldVal {
            width: 150px;
        }

        input.approve {
            background-color: #D0EED0;
        }

        input.reject {            
            background-color: #F0D0D0
        }
    </style>
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table class="taskInfo">
        <tr>
            <td class="header" colspan="4">
                <SharePoint:FieldValue ID="FieldValue1" runat="server" FieldName="Task Name" ControlMode="Display" />
            </td>
        </tr>
        <tr>
            <td class="field">Requested by</td>
            <td class="fieldVal">
                <SharePoint:FieldValue ID="FF_CreatedBy" runat="server" FieldName="Created By" ControlMode="Display" />
            </td>
            <td class="field">Due date</td>
            <td class="fieldVal">
                <SharePoint:FieldValue ID="FF_DueDate" runat="server" FieldName="Due Date" ControlMode="Display" />
            </td>
        </tr>
        <tr>
            <td class="field">Task details</td>
            <td class="longFieldVal" colspan="3">
                <SharePoint:FieldValue ID="FF_Body" runat="server" FieldName="Body" ControlMode="Display" />
            </td>
        </tr>
        <tr>
            <td class="buttons" colspan="4">
                        <asp:Button runat="server" ID="ApproveButton" Text="Approve" CssClass="approve" OnClick="ApproveButton_Clicked"/>
                        <asp:Button runat="server" ID="RejectButton" Text="Reject" CssClass="reject" OnClick="RejectButton_Clicked"/>
                        <SharePoint:GoBackButton runat="server" ID="GoBackButtonn" />
            </td>
        </tr>
    </table>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    <SharePoint:FieldValue ID="FF_TaskName1" runat="server" FieldName="Task Name" ControlMode="Display" />
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    <SharePoint:FieldValue ID="FF_TaskName2" runat="server" FieldName="Task Name" ControlMode="Display" />
</asp:Content>

2. Add codebehind for task form to Approve and Reject.

For that press F7 in VS when you are editing MyCustomTaskForm.aspx to see its codebehind.

Codebehind of the custom workflow task form

Replace text of the class with the following.

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void ApproveButton_Clicked(object sender, EventArgs e)
        {
            CompleteCurrentTask("Approved");
        }

        protected void RejectButton_Clicked(object sender, EventArgs e)
        {
            CompleteCurrentTask("Rejected");
        }

        private void CompleteCurrentTask(string outcome)
        {
            //Completing a task
            var item=SPContext.Current.Item;
            item["TaskOutcome"] = outcome;
            item["PercentComplete"] = "1";
            item["Status"] = "Completed";
            item.Update();

            //Closing the form
            SPUtility.Redirect(string.Empty, SPRedirectFlags.UseSource, Context);
        }

3. Check whether it works.

For that you have to deploy new version of our form (CTRL-F5). After that you could try to edit our task again. You should see the new task form and should be able to complete the task by pressing Approve or Reject buttons.

Our custom workflow 2013 ASP.NET task form

 

Custom workflow 2013 ASP.NET task form

 

After pressing the Approve button, we could see that our task and workflow completes.

Check whether workflow has been completed from the custom ASP.NET task form

 

Hurray!


Conclusion.

During this walkthrough, we have created custom ASP.NET task form for our workflow. This is quite hard to implement (in comparision with the InfoPath task forms). However, this approach has great level of flexibility and you can reuse the most part of your code and styles in it. Frankly speaking, personally, I like this approach much more than custom InfoPath forms. It needs some efforts to implement the first form; however, every another form needs less and less efforts. Also you can easily change the look of all your forms, by changing CSS styles in one place. In addition to that you can implement all the logic that you need. Also you can use jQuery controls and AJAX in this approach. So, this way has almost no limitations! During the other posts I will show you some useful techniques which could help you to like this approach as much as I do. So, stay tuned! 🙂

Have a nice day!

Regards, Michael.

PS: If you have some suggestions, ideas, critisism or just want to talk about SharePoint, don’t hesitate to write me a letter or leave a comment. I like to share my knowledge and your feedback helps me to understand that it is useful for you. Also it helps me to improve the quality of the posts. So, don’t shy to leave a feedback even if it is a comment regarding grammar mistakes! Also you can subscribe to updates by clicking the Follow button in the right bottom of the page. 🙂

Did you find apk for android? You can find new Free Android Games and apps.

54 thoughts on “SharePoint 2013 Workflows. Part 2/3: custom ASP.Net task form

  1. Pingback: Creating SPD 2013 Workflows. Part 1/3: extremely simple workflow and default task form. | SharePoint 2013 Developer's Blog

  2. Pingback: Solution: Workflow cancels (System.ArgumentException: ContentTypeId) | SharePoint 2013 Developer's Blog

  3. Pingback: Custom ASP.NET SharePoint 2013 task form FAQ | SharePoint 2013 Developer's Blog

  4. Thank you very much for really helpful article!
    Can u Please Share
    How to disable Approve,reject buttons once the task was completed in Custom
    aspx Form.

    • Hi Kumar,

      Sorry for the delay. This week was very limited in terms of my time.

      As one possible solution, you can just check whether your task is completed, by checking

      if (SPContext.Current.Item[SPBuiltInFieldId.PercentComplete]==1 && SPContext.Current.Item[SPBuiltInFieldId.TaskStatus].Equals("Completed"))
      {
          //Hide unnecessary buttons
      }

      Hope it gives you some clues. If some questions remain, don’t hesitate to let me know and I’ll describe this in more detail.

  5. Hi Mikhail. Great post! I have used it with success in my SharePoint 2013 project. Now I want to send my workflow and custom forms to the customer in an easy fashion.

    So, I have a workflow developed in SharePoint Designer, that uses a custom content type to connect to the custom task form I have developed. By using Visual Studio I connect the custom task form with the workflow through the custom content type when the feature is activated.

    I have also a custom initiation form that is being called from the standard WFInitForm.aspx. The asp net pages are stored in /_layouts/15/CustomInitiationForms and /_layouts/15/CustomTaskForms

    So, how do I package and send this in an easy manner to the customer, and how do the customer deploy the solution in a non-technical way? Any suggestions?

    • Hi Borge. Thank you for the feedback!
      Regarding moving to the customer. As I understand the most desirable way is to pack all the pieces in the single WSP package. Some parts of your solution are already ready for that (both ASP.NET forms).

      I think, you have the following remaining project items:
      1. Custom content type. The easiest way here is to add new custom content type to your project in Visual Studio (not to copy the created one). I can see two easy ways here: just add new Content Type using right-click on the solution, Add\New Item\Content Type. As alternative way you can add several lines of code to your feature receiver to create necessary content type from code (not only change its EditFormUrl). In the both cases don’t forget that your parent content type should be “Workflow Task (SharePoint 2013)” one.
      2. SPD Workflow. In my case I just used copy/paste approach and have not tried to include it in WSP package. So, I opened source and destination farms in SPDs; started to create a new WF on the necessary list of the production farm; opened source WF, pressed CTRL-A and CTRL-C; opened destination WF and pressed CTRL-V and published WF. In general it is not a so good approach, but it suited my case well. As possible ways to deploy it in your case you can save WF as template. This link should help you in that. However, don’t forget that your both lists should have the same IDs or you can try to manually change them inside WF WSP package. Another possible way is to create VS WF in VS project, but in the latter case it would be impossible to make changes in WF from SPD later. Probably, there are some better solutions, but that are the first things that occurs to mind.

      Also don’t forget that your WSP package which contains forms is a farm solution and should be deployed using PowerShell by the farm administrator, whereas WSP WF Template should be deployed to the solution gallery.

      It is just a quick note, so if I have forgotten some moments or some of the points need more details or discussion, don’t hesitate to let me know and I will find time for that.

  6. Thanks for this helpful article. I just would like to ask for some help. I am trying to do this in my Windows 7 64 bit pc. It has a Sharepoint Foundation 2010 installed and VS2012 Ultimate. Unfortunately, I cannot create an Empty Sharepoint 2013 Project because I dont have a Sharepoint 2013 installed. And by googling, I found out that Sharepoint 2013 cannot be installed in Windows 7. Please help.

    • Hi Ching,
      Yes, you are right. Unfortunately SP2013 can’t be install on Windows 7 (SP2010 can be), because it needs a server OS (Windows Server 2008R2 or Windows Server 2012). Probably, there are some hacks which allow to install it on Windows 7 or deceive Visual Studio, but I am not aware of them and think it is a bad idea to use such an approach.

      However, you can install SP2013 on your computer using virtualization. I mean, you can install virtualization solution on you host Windows 7/8 OS (Oracle Virtual Box or enable Hyper-V on your Windows 8 machine). In such a case you can install guest OS (Windows Server) and SP2013 on it. This approach works well and it provides some pros of virtualization (restore configuration to some point in time quickly). The following link: SharePoint 2013 Best Practices: Creating a Development Environment should help you create your development environment. Hope it helps.

  7. Thank you for this great tutorial ,

    I have a question , what if i want to use external database not a SharePoint list,
    I mean I have an SQL table called tasks and this table has fields ,i want to run a SharePoint workflow on this table

    thank you

  8. Pingback: SharePoint 2013 Workflows. Custom ASP.Net task form | ИТ Блог

  9. Congrats Michael for a well written and extremely useful article. Please advise, are there any workarounds for the “change forms for derived content types” bug, which do not require a farm solution (disallowed in our organization)?

    Thank you!

    • Hi Rosly,
      Thank you very much for your feedback. I am glad to hear that you found this article useful. 🙂
      You can use a sand-boxed solution for that (changing form of content type). I haven’t tested it, but as far as I understand it should work the same way. Please, let me know whether it helps you.

  10. Thank you for this great tutorial ,It is awesome

    I have a question . In workflow 2010 we had ability to set task field on task initial, but now I think that I must set task field on page load, am I right ?
    If it is true, I need to get current item field value in order to set it to task field and reverse. how can I get current item field that workflow run on it ?

    And if it is possible would you explain “Workaround: Tasks activities in its internals use subscribing on item change event to make conclusion if task is completed, so we can change task fields directly and task activity will perform check immediately after that. For instance if we want to reassign our task, we could simply change the “Assigned To” field of the task item.” more ?

    regards,

    • Hi Zahra,

      Thank you for your feedback! Yes, you are right, you can set it in your ASP task form. You can obtain current item using the piece of code I showed here: How to get a reference to a related item from SharePoint 2013 task form?.

      Regarding the workaround and task subscribing events. I wanted to say that now, old SP2010 workflow approach to change task from code (to complete it for example), doesn’t work anymore. But we can just change necessary task item (which is located in our tasks list) to make changes. That way Workflow will be notified about such a change and will execute necessary logic.

      So, for instance, you have created a task in your 2013 workflow and want to complete it from code. Now, you can manipulate with the task item, related with your task activity from the code using the same approach which you would use for general list item. Workflow will be notified about changes. If you want to complete the task you can just set its “Status” field to “Completed”, “PercentComplete” to “1” and “TaskOutcome” to “Approved” and workflow will know that the task is completed with the Approved outcome and will go to the second step.

      If your question was about “how it works behind the scenes” and how I understood this moment, then you can take a look at DB. There is an XAML definition of the task activity, where you can find subscribtions to the changing event. Let me know, if your question was about this point and I’ll provide the answer with more details about that.

      Regards, Michael

  11. Thank you for this great article ….

    I have one question, Is there a way to access the original list item in the code behind ? lets say I want to update the task status and also update some columns in the parent list which I run the workflow on its items

    Thanks again

  12. Hi Michael,

    I would like to know how can I implement “RequestChange” in workflow2013. I think that I can add new outcome as “requestchange” and after task complete , I must check outcome and if it is equal to “requestchange” therefore I will create new task for workflow initiator. Am I right?

    thanks

    • Hi Zahra,
      Sorry for the delay with the answer. Just in case if the question is still actual for you.
      Yes, actually it is one of the possible ways to go. If your workflow is rather simple, you can use this approach without any hesitations. I planned to write the final third article of this series where I wanted to show another way which could be useful if you have rather big workflow and don’t want to implement additional steps for each task. Briefly, I wanted to show how to use the same task and its different form views to implement some sort of Request change behaviour without adding additional workflow steps. I hope I’ll find some spare time in the nearest future to write this article as I see the demand for it.
      Regards, Michael.

    • Hi Prabath,
      Unfortunately, this solution is not applicable for SP Online (Office 365), because it contains a Farm solution. For SP Online you have to use another approach. You can use the new apps model to create a solution. This way you can communicate with Workflows using CSOM (Working with the SharePoint 2013 Workflow Services Client Side Object Model). Unfortunately, I haven’t stumbled into a good article about that in SP Online, but probably, you’ll find some. If so, please share it in comments. Probably, I’ll find some time and will write an article about that.

  13. SPContext.Current.Item[“TaskOutcome”] = outcome;
    SPContext.Current.Item[“PercentComplete”] = “1”;
    SPContext.Current.Item[“Status”] = “Completed”;
    SPContext.Current.Item.Update();

    gives following exception.
    System.NullReferenceException: Object reference not set to an instance of an object. at KRAKPIWorkFlow.Layouts.KRAKPIWorkFlow.SheetDemo.CompleteCurrentTask(String outcome)

    • Hi Keyer,
      Sorry for the delay with the answer.
      From your issue it seems there is no SPContext and hence you can’t get reference to a current item.
      Do you do all the steps as it shown in this article or you have changed something?

  14. Initiator: Keyur Pandya
    Item: (no title)
    Started: 5/21/2014 4:02 PM
    Internal Status: Started
    How to set item????

  15. Hello Michael,

    Very nice and clear article. I have one question.

    I have to develop a sp2013 WF using VS. Can I use the above approach to create custon task edit form for a WF created using VS? If not, can you help me a good article on web?

    Thanks.
    Yogesh

    • Hi Yogesh,
      Yes, you can. In general, you have just to change step 2 of this article to your own. In this step you have to change the EditFormUrl of your custom task content type to make it link to your custom task ASPX form.
      If you stumbled into some issues, just let me know, I’ll write more detailed description.
      Regards, Michael

      • _layouts/blogtest/Product.aspx?mode=display _layouts/blogtest/Product.aspx?mode=edit
        _layouts/blogtest/Product.aspx?mode=new

        Please have a look above code. I am using custom task form form in SP2013 VS Workflow. But it is not showing and even I am not getting any error.

        Please suggest.

        Thanks

  16. Thank you Michael for your great work! It’s a tremendous improvement for our department. I just want to add, that I had to instantiate SPSite before opening its Web to get the event-reciever working:
    using (SPSite site = (SPSite)properties.Feature.Parent)
    {
    SPWeb web = site.OpenWeb();
    SPContentType ct = web.ContentTypes[“CustomContentTypeForTaskList_G”];
    ct.EditFormUrl = “_layouts/15/customApproveForm/custForm.aspx”;
    ct.Update(true);
    }

    • Thank you very much for your feedback. Actually, your comment make me take a look at my code and I found a silly mistake in it. I disposed SPWeb in the feature event receiver (using{}), but I should not do that. I have updated this code in my post. I’ll change the screenshot of it and will add some comments regarding SPSite a bit later. Thanks! 🙂

  17. Pingback: URL’s for your reference | Kollipara's space

    • Thank you very much, Johny.
      I’ll try to find time for that in the nearest future, but for a while I don’t know when it will be as it is quite hard in terms of my spare time now. Thank you for commenting, now I know that definitely should try to find time for that. 🙂

  18. Thanks for your brilliant and useful post!

    I have one question, if you don’t mind to answer.
    What shall I do (I mean what technique shall I use) to add the fields into the custom aspx form, accordingly to the inherited (from WFtask2013) custom task content type, for the edit mode?

    My will would be to bound the content type definition to a given control that would render the controls automatically, meaning that whenever the content type changes the form would automatically be updated.
    However I think this is not possible (is it?). What alternatives do we have to render the form fields controls accordingly to the content type of the task?

    Regards
    Mario.

  19. How can we update the workflow task via a custom webpart (farm solution). Tried updating the workflow task item, the taskitem gets updated but the status of workflow does not change. No action happens on workflow after updating the workflow task item.

  20. Hello,

    I have created custom task forms and sharepoint designer workflow. I want to retrieve fields of current list item and displayed it in task form.
    Suppose I have one field in list named “Department”. When I create new item in list I fill the value of it. Then on submit , the workflow will be stated and the task will be assigned to particular assignees . Now I want “Department” column value in custom task form.
    How can I achieve this?

  21. Dear Admin,

    Thanks for sharing this wonderful post. In my case, it works perfectly for SharePoint 2013 On-Premises version. But I just wanted to do the same changes in SharePoint Online Workflow task form. How to do that?
    Because, we cant deploy this farm solution into SharePoint online and if we change the solution type to Standalone version, then the existing code will not work (due to LayoutsPageBase is not supported by Standalone version).

    Please suggest a solution to do this in SharePoint online.

Leave a Reply

Your email address will not be published. Required fields are marked *