Content Type Lookup with cross-site column
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 KozlovAdminMember for: 9 years 4 months 11 days
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 ManavMemberMember for: 8 years 2 months 24 days
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 ManavMemberMember for: 8 years 2 months 24 days
[#2]: I want to use it like cascading drowndown.But first dropdown will be content type column.
-
Dmitry KozlovAdminMember for: 9 years 4 months 11 days
[#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 ManavMemberMember for: 8 years 2 months 24 days
[#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 ManavMemberMember for: 8 years 2 months 24 days
[#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 MohamedMemberMember for: 6 years 6 months 5 days
[#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 KozlovAdminMember for: 9 years 4 months 11 days
[#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 MohamedMemberMember for: 6 years 6 months 5 days
[#8]: how do i get the value of this plain text control via javascript ?
-
Dmitry KozlovAdminMember for: 9 years 4 months 11 days
[#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()