Content Types & Related items

rss

Posted by Hubbaroo - Sep 30 ’13 at 05:57

We are clear on how to create a related item using the information contained in this site. We would like to understand how to create a related item in a list with multiple content types. The current method only creates the default content type. Can you explain how to, based on a field in the parent form, create the related item using other than the default content type.

 

Thank you.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #1 by Dmitry Kozlov Oct 4 ’13 at 05:16

    Hello,

    You can override the standard function NewItem2 and inject the specific content type id into the new item link by placing the following code into JS-editor of Forms Designer:

    var contentTypeId = '0x010600818BDDA1EEF42845841F01B81D898F04';
    
    if (typeof (window.NewItem2) === "function") {
      var NewItem2Orig = window.NewItem2;
      window.NewItem2 = function (evt, url) {
        var ch = url.indexOf('?') >= 0 ? '&' : '?';
        url += ch + 'ContentTypeId=' + contentTypeId;
        return NewItem2Orig(evt, url);
      }
    }
    

    You have to set contentTypeId variable in the required content type id. To get it go to the list settings, select the specific content type and find ctype parameter in the query string. It contains the ID of the selected content type.

Displaying 1 to 1 of 1 messages