Cross site lookup field deployment

Discussions about Cross-site Lookup
Locked
User avatar
Андрей Тарутин
Posts: 13
Joined: Mon Aug 25, 2014

26 Aug 2014

Lookup column looks good and works fine. It's worth mentioning that in most cases data model provision (columns, content types, lists) is done within visual studio solutions. It could be xml provision or provision using API, depends on developer. How could I provision cross site lookup fields, let's say with xml provision? Could you provide a consistent example of your lookup field provision?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

26 Aug 2014

Hi Andrew,

Cross-site Lookup schema is similar to the out-of-the-box lookup but contains additional attributes. Here's an example:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Field
  Type="Lookup"
  Name="Country" 
  DisplayName="Country" 
  JSLink="~sitecollection/style library/plumsail/crosssitelookup/clienttemplates.js?field=Country" 
  xmlns:csl="Plumsail.CrossSiteLookup" 
  Mult="FALSE" 
  csl:ShowNew="false" 
   csl:RetrieveItemsUrlTemplate="function (term, page) {&#xA;  if (!term || term.length == 0) {&#xA;    return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&amp;$orderby=Created desc&amp;$top=10&quot;;&#xA;  }&#xA;  return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&amp;$orderby={LookupField}&amp;$filter=startswith({LookupField}, '&quot; + encodeURIComponent(term) + &quot;')&amp;$top=10&quot;;&#xA;}" 
   csl:ItemFormatResultTemplate="function(item) {&#xA;  return '&lt;span class=&quot;csl-option&quot;&gt;' + item[&quot;{LookupField}&quot;] + '&lt;/span&gt;'&#xA;}" 
  ID="{93c08653-b2e1-4342-b04f-8f32596b6633}" 
  SourceID="{fce5ae43-52aa-4f03-aa93-667112e7b5ce}" 
  StaticName="Country" 
  ColName="int1" 
  RowOrdinal="0" 
  Version="2" 
  WebId="{78a5e7dd-b782-4b2d-bf9a-893b5193d4ab}" 
  List="{275da0fb-d2cc-42c6-b82a-ed16ca87ea98}" 
  ShowField="Title" 
  csl:NewText="Add new item" 
   csl:NewContentType="" />
So, you can provision it like any other field declaratively or programmatically.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest