Content Type Lookup with cross-site column

rss

Posted by Gökhan Manav - Dec 3 ’14 at 04:55

Hi;

How can we create lookup column with content type using cross-site column?

I must filter column by content types;

 

Thanks..

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #1 by Dmitry Kozlov Dec 4 ’14 at 04:29

    Hi,

    Do you mean you need to filter lookup values by their content type? If so, please, modify Request items template of the Cross-site Lookup column following way:

    function (term, page) {
      if (!term || term.length == 0) {
        return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Created desc&$top=10&" +
        "$filter=ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D'";
      }
      return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&" +
        "$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') and " +
        "ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D'&$top=10";
    }
    

    Replace Id in the code above with your content type Id.

  • Gökhan Manav
    Gökhan Manav
    Member
    Member for: 4 years 9 months 12 days
    #2 by Gökhan Manav Dec 4 ’14 at 06:43

    I have 5 content types on the spform.And I have a cross-site lookup up column.It name ise SubBusinessLine.

    I put content type columns and SubBusinessLine columns to all content type pages(5 page).My page changing which content type selected.But I can not lookup column filter by which content type selected.SubBusinessLine column must be filter by content type column.We can see content type like column on designer but on the list settings there hasn't any column fot content type,

     

  • Gökhan Manav
    Gökhan Manav
    Member
    Member for: 4 years 9 months 12 days
    #3 by Gökhan Manav Dec 4 ’14 at 08:54

    [#2]: I want to use it like cascading drowndown.But first dropdown will be content type column.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #4 by Dmitry Kozlov Dec 8 ’14 at 10:23

    [#3]: You can use Content type as any other field. Just drop it onto your form in Forms Designer and you will be able to get the selected content type Id via JavaScript:

    fd.field('ContentType').control()._el().find('select').val()

    Use the selected value in the Request items template as I demonstrated above to filter the dependant Cross-site Lookup field.

  • Gökhan Manav
    Gökhan Manav
    Member
    Member for: 4 years 9 months 12 days
    #5 by Gökhan Manav Dec 9 ’14 at 01:05

    [#4]:

    I resolved this problem using different long way.

    I have many content type and many pages on form designer.I created text column which has content type name.

    And I set this column manuel(with javascript) for all content type pages.And then I got this field value from cross-site lookup.

    But I will try your short way.

    Thanks for your reponse..

  • Gökhan Manav
    Gökhan Manav
    Member
    Member for: 4 years 9 months 12 days
    #6 by Gökhan Manav Dec 9 ’14 at 01:17

    [#4]:

    I resolved this problem using different long way.

    I have many content type and many pages on form designer.I created text column which has content type name.

    And I set this column manuel(with javascript) for all content type pages.And then I got this field value from cross-site lookup.

    But I will try your short way.

    Thanks for your reponse..

  • Mostafa Mohamed
    Mostafa Mohamed
    Member
    Member for: 3 years 23 days
    #7 by Mostafa Mohamed Jul 27 ’16 at 09:06

    [#4]: Although i have 2 content types on my list i can't find the content type column on forms designer to include it on my form and get its value.

    please advice

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #8 by Dmitry Kozlov Jul 27 ’16 at 10:16

    [#7]: Hi,

    If you're using SharePoint Online, you can display the content type field in the read-only mode only by placing Plain or Rich text control with the following content:

    [ContentType]
  • Mostafa Mohamed
    Mostafa Mohamed
    Member
    Member for: 3 years 23 days
    #9 by Mostafa Mohamed Jul 27 ’16 at 10:25

    [#8]: how do i get the value of this plain text control via javascript ?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #10 by Dmitry Kozlov Jul 28 ’16 at 05:49

    [#9]: Hi,

    Assign a CSS-class to the Plain Text control, say 'content-type-value'. Then use it in JS-code to get the content:

    $('.content-type-value').text()
Displaying 1 to 10 of 13 messages
Previous12