1

I have a custom content type, inheriting from the WorkflowTask content type. I've configured the content type to point to a custom form, but the URLs are not working properly.

<ContentType
    ID="0x01080100E6578EE7F3CD4BCA8C6EA42C8FF3F24B"
    Name="Custom Task Content Type"
    Group="Custom Content Types"
    Description=""
    Inherits="TRUE"
    Version="0"
    Overwrite="TRUE"
>
    <FieldRefs>
        <FieldRef ID="{5E9EDA01-AFAF-4c6d-A3C4-A44C8418E519}" Name="_ApprovalNotes"/>
        <FieldRef ID="{886F1812-47CE-4cd7-AF93-C57EF5EBD171}" Name="_ApprovalStatus"/>
        <FieldRef ID="{CFB3DE92-106B-4c3e-84D2-9FBC3A3C5921}" Name="_Delegate"/>
        <FieldRef ID="{B923E7D6-7C56-447b-95A9-5CFB7854F7B7}" Name="_taskType"/>
    </FieldRefs>
    <XmlDocuments>
        <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
            <FormUrls>
                <New>_Layouts/project/custom Form.aspx?PageMode=New&amp;WFTask=1</New>
                <Edit>_Layouts/project/custom Form.aspx?PageMode=Edit&amp;WFTask=1</Edit>
                <Display>_Layouts/project/custom Form.aspx?PageMode=Display&amp;WFTask=1</Display>
            </FormUrls>
        </XmlDocument>
    </XmlDocuments>
</ContentType>

When adding this content type to the built-in Tasks list, the custom form URLs are not carried over. So in the FeatureActivated event receiver, I have this code:

SPContentType ct = taskList.ParentWeb.AvailableContentTypes[contentTypeName];
if (ct != null)
{
    taskList.ContentTypes.Add(ct);
    taskList.Update();

    SPContentType ct2 = taskList.ContentTypes[contentTypeName];
    ct2.NewFormUrl = "_Layouts/project/custom Form.aspx?PageMode=New&WFTask=1";
    ct2.EditFormUrl = "_Layouts/project/custom Form.aspx?PageMode=Edit&WFTask=1";
    ct2.DisplayFormUrl = "_Layouts/project/custom Form.aspx?PageMode=Display&WFTask=1";
    ct2.Update();
}

Unfortunately, when I open the workflow task form, the received query string contains the key amp;WFTask rather than WFTask. Why is the ampersand XML encoded and then directly used in the querystring rather than being decoded back to a proper ampersand? How do I fix this?

1
  • 1
    As a work-around, I'm checking the querystring for the "amp;WFTask" key if "WFTask" is not found - this works, but in my development I've seen cases where the encoding resulted in "amp;amp;amp;WFTask" - as though it had been encoded three times. Commented Sep 12, 2013 at 14:06

1 Answer 1

2

Use %26 instead of &. It helped me. Like here:

<Edit>_Layouts/project/custom Form.aspx?PageMode=Edit%26WFTask=1</Edit>
2
  • Odd that that may work, I would assume the %26 would cause the PageMode parameter to equal Edit%26WFTask=1 rather than giving me two parameters. I may try this in the future, but right now the work-around functions and I'm under a time crunch to finish. Commented Oct 22, 2013 at 12:51
  • When I finally got time to test this (need to resolve became necessary when one of our environments double-encoded the ampersand $amp;amp;WFTask=1) the %26 encoding resolved the problem. Commented Oct 27, 2013 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.