2

I have been researching this for a while now and no where can I find a solution that works perfectly in a list with multiple content types. I needed to create hyperlinks on a page where the user could click the link and in modal view the "New Form" would open in modal view for them. I have finally achieved this and here is how you do it...

Use the following code below to create a hyperlink that will open the "New Form" for a specific content type...

    <a class="ms-addnew" id="idHomePageNewItem" onclick="javascript:NewItem2(event, &quot;http://**Insert URL to List i.e. /sites/subsite/List**/_layouts/listform.aspx?PageType=8&amp;ListId={**Insert the List ID**}&amp;RootFolder=**Insert Root Folder for that List and Content Type**&amp;ContentTypeID=**Insert Content Type ID**&quot;);javascript:return false;" href="**Insert URL to List i.e. /sites/subsite/List**/_layouts/listform.aspx?PageType=8&amp;ListId={**Insert the List ID**}&amp;RootFolder=" target="_self">Insert Name of HyperLink</a>

You can get the content type ID from the URL in the content type settings under the your sites settings > content types > select the content type

You can also get most of this information if you open the content type form in the list using the "New Item" drop down under the "Items" tab at the top. Select the content type then right click in the modal pop up of the content type form and select "view source" (works in IE). At the top the URL path will contain the Root Folder ID and content type ID.

To get the list ID, the easiest way is to go the list settings. In the URL at the end select the %7B*List ID*%7D. Remove the %7B and the %7D then replace all the %2D with dashes (-).

Insert all this information into the code string above and this should work for you. Also just because someone may get confused, the ** before and after my comments in the code string are not part of the code!

  • 1
    Please add your update as an Answer! That way you will be able to mark it as your accepted solution, and future readers will be able to easily find your solution. – Robert Lindgren Mar 3 '14 at 14:17
2

I am correcting this answer due to finding flaws with editing forms and content types using this type of hard coded link. Please follow the same steps except use this code string below...

http://sites/yoursite/yourlist/_layouts/listform.aspx?PageType=8&ListId={D2035BDF-0FA5-4EA1-A9D4-26DC988E214C}&ContentTypeId=0x010032D35BB93EAA624BA6D15A22B6B8A25201005D65581BF100AE4CB6C27AC6A66546EC&RootFolder="); javascript:return false;" href="/_layouts/listform.aspx?PageType=8&ListId={D2035BDF-0FA5-4EA1-A9D4-26DC988E214C}&ContentTypeId=0x010032D35BB93EAA624BA6D15A22B6B8A25201005D65581BF100AE4CB6C27AC6A66546EC&RootFolder=" target="_self"> New Content Type

Be sure to use your content type ID and List ID and replace mine.

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.