3

I want to use a custom application page for my workflow task view/edit form, I searched the internet and find it is possible to set url for content type's edit/view form, my code to update task's form is this: (this question has nothing to do with Workflow however)

Web.AllowUnsafeUpdates = true;
var taskList = Web.Lists["Tasks"];
var wfContentType = taskList.ContentTypes["Workflow Task"];
wfContentType.DisplayFormUrl = "_layout/WorkflowTaskForm.aspx";
wfContentType.Update();
taskList.Update();
Web.AllowUnsafeUpdates = false;

However, my form is not showing as expected, When I click on the list item, I am redirected to this page:

mysite.com/_layouts/listform.aspx?PageType=4&ListId={0613FA06-BD63-42F1-820F-78106FD2B4F8}&ID=546&ContentTypeID=0x0108010065CBC91109B00342A1F22B241DF80C0D&Source=http%3A%2F%2Feric%2Fwf3%2FLists%2FTasks%2FAllItems%2Easpx

Seems other guys are successful with this method, I have no idea where I was wrong, could some one kindly help me? Thanks Very Much! I was referring to these resources:(use SPContentType.DisplayFormUrl to specify its form)

http://social.technet.microsoft.com/Forums/sharepoint/en-US/d03ae2db-7fde-4da2-a1d0-251eb51ddfd5/sharing-custom-forms-between-lists-possible?forum=sharepointgeneralprevious

http://blog.qumsieh.ca/2009/05/15/how-to-change-the-default-editform-newform-and-dispform/

  • 1
    It is not clear what you are asking. Your code seems to be about a workflow form. Your question starts with a statement about a content type form. The first link is about using a form for two different SP lists. The second link is full of comments asking how to implement this and stating that it does not work. So, what exactly do you want to achieve? Please step back. Describe the functional spec, without getting into details about forms or pages. What does your solution need to do? – teylyn Jan 9 '14 at 7:55
  • I will update my question, thanks teylyn, looking to your help – Wint Jan 9 '14 at 7:59
2

It turns out to be my fault. I was using absolute url for the DisplayFormUrl property, when I changed it to relative url (/_layout/WorkflowTaskForm.aspx), everything works just fine. (so the code snippet in my question works)

Your Answer

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

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