Page 1 of 2

Content Type Lookup with cross-site column

Posted: 03 Dec 2014
by Gökhan Manav
Hi;

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

I must filter column by content types;


Thanks..

Re: Content Type Lookup with cross-site column

Posted: 04 Dec 2014
by Dmitry Kozlov
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:

Code: Select all

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.

Re: Content Type Lookup with cross-site column

Posted: 04 Dec 2014
by Gökhan Manav
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,

Re: Content Type Lookup with cross-site column

Posted: 04 Dec 2014
by Gökhan Manav
I want to use it like cascading drowndown.But first dropdown will be content type column.

Re: Content Type Lookup with cross-site column

Posted: 08 Dec 2014
by Dmitry Kozlov
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:

Code: Select all

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.

Re: Content Type Lookup with cross-site column

Posted: 09 Dec 2014
by Gökhan Manav
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..

Re: Content Type Lookup with cross-site column

Posted: 09 Dec 2014
by Gökhan Manav
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..

Re: Content Type Lookup with cross-site column

Posted: 27 Jul 2016
by Mostafa Mohamed
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

Re: Content Type Lookup with cross-site column

Posted: 27 Jul 2016
by Dmitry Kozlov
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:

Code: Select all

[ContentType]

Re: Content Type Lookup with cross-site column

Posted: 27 Jul 2016
by Mostafa Mohamed
how do i get the value of this plain text control via javascript ?