SharePoint Integration: How to keep existing SQL foreign key relationships and map to SharePoint lookups

 

You can easily integrate almost any external data source with native SharePoint lists using the Layer2 Business Data List Connector, especially SQL tables or queries. But how to map existing SQL foreign key table relationships to SharePoint lookups? See below for a simple workflow-based approach.

 

 

No problem to sync SQL tables or queries with native SharePoint lists using the Layer2 Business Data List Connector. But how to map existing foreign key relationships between these tables to SharePoint lookups? Generally you can solve these issue using a workflow approach as shown in the sample below.

 

1-SQL-Source-Tables-for-SharePoint.png

Fig.: Sample database schema with two tables that are in a foreign key relationship.

 

 

The table ‘Cars’ contains a column with the name ‘ColorCode’. The column contains a reference (foreign key relationship) to the column ColorID in the table ‘Colors’. You have to create both lists (cars and colors) in your SharePoint and connect the lists via the BDLC with the tables as usual. See product description for more details.

 

2-SharePoint-Target-Lists.png

Fig.: SharePoint lists connected to the database tables via BDLC

 

 

In the list ‘cars’ you have to create an additional lookup column manually, for example with name ‘Color Value Lookup’. This is a lookup field to the list ‘Car Colors’ to the field ‘Color’. If you start the update mechanism for both lists, you can see that the lookup column isn’t filled with values automatically. To create this association in SharePoint, you have to create a workflow for this list, which starts if an item is created or updated.

 

3-SharePoint-Workflow-Set-Lookup.png

Fig.: SharePoint Designer Workflow

 

 

First of all create an action ‘Set Field in Current item’. After this step you can specify the field and value to set. Select the manually created Lookup field. In this case ‚Color Value Lookup‘.

 

4-SharePoint-Workflow-Set-Lookup.png

Fig.: Select Values to set in the SharePoint Designer workflow. 

 

 

In the next step you have to select the value which the field should be filled with.

 

5-SharePoint-Workflow-Set-Lookup.png

Fig.: Select Values to set in the SharePoint Designer workflow.

 

 

Select the data source list (‚Car Colors‘) and the field ‚ID‘ of this list.

 

6-SharePoint-Workflow-Set-Lookup.png

Fig.: Select Values to set in the SharePoint Designer workflow.

 

 

7-SharePoint-Workflow-Set-Lookup.png

Fig.: Select Values to set in the SharePoint Designer workflow.

 

 

In the next step you can specify the ‘primary key information’ (ColorCode) in list ‘Car Colors’ and the associated field ‘ColorCode’ in the current list. If you save your settings, there is a popup message with a warning, that your selection isn´t a field with unique values. You can ignore this and save the settings with ‚Yes‘.  

 

8-SharePoint-Workflow-Set-Lookup.png

Fig.: Save your workflow settings. 

 

 

Now you are done with the workflow creation. To publish it, press the button ‘Publish’ in the ribbon.

 

9-SharePoint-Workflow-Set-Lookup.png

Fig.: Publish your workflow. 

 

 

As a next step you can update the SharePoint list ‘Cars’ using the BDLC ribbon button.

 

10-SharePoint-Sync-External-Data.png

Fig.: Update list items with external data via BDLC manually. 

 

 

If you currently have items in the list, you have to delete all of them and update again. Thats because of the BDLC changes only modified items. The lookup field is now filled with the information from the list ‘Car Colors’.

 

11-SharePoint-Foreign-Key-to-Lookup.png

Fig.: The lookup field is now automatically maintained by the workflow in case of any data changes. 

 

 

If the workflow didn’t work as expected, you have to resave the BDLC settings by clicking ‘OK’ in the BDLC settings page and update your list again. Please note that this can be used as a replacement for the Layer2 Key Value Lookup Column product that will be not available for SharePoint 2013.

Summary

 

Existing foreign key relationships between normalized SQL tables were mapped to SharePoint lookup-type relationships using the Layer2 BDLC to connect to the external data and simple SharePoint Designer workflows to keep the lookups current in case of external data changes.

READY TO GO NEXT STEPS?

Layer2 leading solutions product regsitration icon: a grey square with a big orange pen symbol.

Register for free download

Keep your Sharepoint in sync. Download and try today.

Contact Us Icon for Layer2 leading solutions

Questions? Contact us.

We are here to help. Contact us and our consulting will be happy to answer your questions.