CrossSiteLookup for external List / BDC / BCS

Discussions about Cross-site Lookup
Locked
ragesoft
Posts: 50
Joined: Fri Feb 23, 2018

22 Mar 2019

Hi,

i've allready ask this question in the past, but maybe there is still a way to achive this?
viewtopic.php?f=5&t=2007&p=6327&hilit=e ... list#p6327

I'm able to provision the CrossSite-Lookup via JavaScript as a Website-Column.
If i define it as a normal Lookup column, to point to a external List, i'm able to create a normal CrossSiteLookup field. I can search for items in the external list. But i cant save the value.
In the Screenshot "CrossSiteLookup_ExternalData_Lookup.png" you see the lookup with BdcIdentity as Lookup-Column and "Titel" as additional value.
The field schema looks like this:

Code: Select all

<Field Group="_MyGroup" xmlns:csl="Plumsail.CrossSiteLookup" 
csl:NewContentType="" 
csl:NewText="" 
csl:ItemFormatResultTemplate="function(item) {&#xA; return '&lt;span class=&quot;csl-option&quot;&gt;' + item[&quot;{LookupField}&quot;] + ' - ' + item[&quot;Titel&quot;] + '&lt;/span&gt;';&#xA;}" 
csl:RetrieveItemsUrlTemplate="function (term, page) {&#xA; if (!term || term.length == 0){&#xA; return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Titel&amp;$orderby={LookupField} asc&amp;$top=10&quot;;&#xA; } return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Titel&amp;$orderby={LookupField}&amp;$filter=startswith({LookupField},'&quot; + encodeURIComponent(term) + &quot;')&amp;$top=10&quot;;&#xA;}" 
csl:ShowNew="false" 
ShowField="BdcIdentity" 
List="{2f5a28ed-fd89-4cb5-8024-ae89defad50d}" 
WebId="{a8d4e0de-9c70-467e-9105-2c5f1dbdb6b3}" 
Mult="FALSE" 
JSLink="~sitecollection/_layouts/15/plumsail/crosssitelookup/clienttemplates.js?field=TestColumnLookup" 
Required="FALSE" 
DisplayName="ExternalLookup" 
Name="TestColumnLookup" 
Type="Lookup" 
ID="{35aba184-5e02-4cf2-9681-d64f5daef07f}" 
SourceID="{a8d4e0de-9c70-467e-9105-2c5f1dbdb6b3}" 
StaticName="TestColumnLookup" /> 

If i defnie it as a normal BusinessData column, but with the csl for crosssitelookup as JSLink, it dosnt render and im getting this error:
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei XgFcmC1xTrcISwPFCT.SGUPD7vHtpq3qLiS8d..ctor(XDocument )
bei Plumsail.CrossSiteLookup.JSInitializer.RWUTGCZ4U(HttpContext )

The schema for this field looks like this:

Code: Select all

<Field Group="_MyGroup" xmlns:csl="Plumsail.CrossSiteLookup" 
csl:NewContentType="" 
csl:NewText="" 
csl:ItemFormatResultTemplate="function(item) {&#xA; return '&lt;span class=&quot;csl-option&quot;&gt;' + item[&quot;{LookupField}&quot;] + ' - ' + item[&quot;Titel&quot;] + '&lt;/span&gt;';&#xA;}" 
csl:RetrieveItemsUrlTemplate="function (term, page) {&#xA; if (!term || term.length == 0){&#xA; return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Titel&amp;$orderby={LookupField} asc&amp;$top=10&quot;;&#xA; } return &quot;{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Titel&amp;$orderby={LookupField}&amp;$filter=startswith({LookupField},'&quot; + encodeURIComponent(term) + &quot;')&amp;$top=10&quot;;&#xA;}" 
csl:ShowNew="false" 
JSLink="~sitecollection/_layouts/15/plumsail/crosssitelookup/clienttemplates.js?field=TestColumnBusinessData" 
Required="FALSE" 
DisplayName="ExternalBusinessData" 
Name="TestColumnBusinessData" 
Type="BusinessData" 
EnforceUniqueValues="FALSE" 
ID="{0a7be7d8-efe5-4845-bce5-d330716f503a}" 
SourceID="{a8d4e0de-9c70-467e-9105-2c5f1dbdb6b3}" 
StaticName="TestColumnBusinessData" 
Version="3" 
SystemInstance="SQL_Archiv" 
EntityNamespace="https://portal/teams/dev" 
EntityName="Test_Content" 
BdcField="Titel" 
Profile="" 
HasActions="True" 
SecondaryFieldBdcNames="0" 
RelatedField="Test_Content_ID12" 
SecondaryFieldWssNames="0" 
RelatedFieldBDCField="" 
RelatedFieldWssStaticName="Test_Content_ID12" 
SecondaryFieldsWssStaticNames="0" AddFieldOption="Default" /> 
Attachments
CrossSiteLookup_ExternalData_Lookup.png
CrossSiteLookup_ExternalData_Lookup.png (4.72 KiB) Viewed 11161 times

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

25 Mar 2019

Dear ragesoft,
Sadly, I do not think it is fully possible. There might be a way, but we did not manage to do it. If you do manage - please, let us know!
Cheers

ragesoft
Posts: 50
Joined: Fri Feb 23, 2018

01 Apr 2019

Hi Nikita,

what is a good starting point to realize a custom CSL for external Lookup fields?

My approche to overwrite the schema donst work until now. If i place the field inside a SPForm it also crashs the edit-form with a message "webpart page cannot be displayed"....

So, can i create somethink like a custom display template and reuse the init method of the crosssitelookup lib?

as far as i can see, the init starts in the jsinitializer for each field.
And then it is processed by "Plumsail.CSL.CrossSiteLookup.Init"


Can i use the "Template" "Custom" and some sort of JS to manipulate a default external lookup inside the spform?
The default html for a normal lookup looks like this (if i get it right):

Code: Select all

<div class="plumsail-csl" id="cslRoom" fd_lookup_field="Title">
      <img width="16" height="16" class="plumsail-csl-loading" style="display: none;" alt="" src="/_layouts/15/images/loadingcirclests16.gif"></img>
      <div class="select2-container plumsail-csl-textbox select2-allowclear" id="s2id_ctl00_ctl45_g_74546812_70fc_45d2_b81a_f05476eeed5f_RoomField"></div>
      <input name="ctl00$ctl45$g_74546812_70fc_45d2_b81a_f05476eeed5f$RoomField" tabindex="-1" title="" class="plumsail-csl-textbox" id="ctl00_ctl45_g_74546812_70fc_45d2_b81a_f05476eeed5f_RoomField" style="display: none;" type="text" value="&lt;a onclick=&quot;OpenPopUpPage(&apos;https://portal/admin/_layouts/15/listform.aspx?PageType=4&amp;ListId={fe7f98fa-f222-44d1-8226-96d5f01daa93}&amp;ID=2&amp;RootFolder=*&apos;, RefreshPage); return false;&quot; href=&quot;https://portal/admin/_layouts/15/listform.aspx?PageType=4&amp;ListId={fe7f98fa-f222-44d1-8226-96d5f01daa93}&amp;ID=2&amp;RootFolder=*&quot;&gt;Schaltraum&lt;/a&gt;"></input>
      <br></br>
      <a href="https://portal/admin/_layouts/listform.aspx?PageType=8&amp;ListId=fe7f98fa-f222-44d1-8226-96d5f01daa93">Hinzufügen</a>
      <br></br>
      <script language="javascript" type="text/javascript"></script>
      </div>
</div>

Thx alot!

ragesoft
Posts: 50
Joined: Fri Feb 23, 2018

01 Apr 2019

Some addon:

Inside SPForm-form, i have the ability, to read and set the normal external Lookup:

Code: Select all

fd.field("ExternalLookup").value({key:'__bk090063007300330053003300430033006300d2004400430034008300d2008300440023004300d2001400530034003400d200140013005400230053005300440064001400930033006300',text:'Aramsamsam'})
So "all" i need now, is to overwrite the default rendering of this field :)
I want to init it s crosssitelookup and the the field value on submit or on change or what ever :)

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

01 Apr 2019

Dear Ragesoft,
I am not quite sure you could use Cross-site Lookup field here, it would probably be easier to just create your own field similar to it in functionality.

I guess you could try to use something like custom template - https://spform.com/custom-fields/custom ... nline-mode
Or maybe even create an HTML field with HTML control, and use JS to save value to SharePoint field, though I do guarantee that this will work.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests