Show data from a different data source in the detailed view

Hi,
I need to show data from another data source in the detailed view of an LFD item. It does not need an accordion. I just want to display it the way I would display data from the Data View Settings.

Hi Catalina,

You will need custom code for this feature. Is this for the directory template? If so you can use an existing or create your own displayList helper and call that from the data view settings. Without the accordions around it.

Hi Deb,
No, it’s actually for the Remote and Office Management template. Do you have a code snippet you could share or maybe a location where I might find an example I could copy and modify within the template?

Hi Catalina,

This example is a simple one where I am grabbing the checkin data for the users and displaying it in the detail view of the staff directory.

Screen JS:

Fliplet.Hooks.on('flListDataAfterGetData', function(options) {
//change DS ID below
  return Fliplet.DataSources.connect(123456)
    .then(function(connection) {
      return connection.find();
    })
    .then(function(externalRecords) {
      _.forEach(options.records, function(record) {
        var foundEntry = _.find(externalRecords, function(externalRecord) {
          if (externalRecord.data.Email === record.data.Email) {
            return true;
          }
        });
       //I am looking for a record matching on email across the LFD DS and the external DS
        if (foundEntry) { 
      //change CheckedIn below to the data attribute you want to display in the detail view
          _.set(record, 'data.CheckedIn', foundEntry.data.CheckedIn);
        }
      });
    });
});

In order to display the column in the data view settings you need to create an empty column in the DS that the LFD pulls data from. In this case it is CheckedIn. Once you have done this you can then select the column in the data view settings. Thats it!

Hope this helps,
Deb

Hi again,
I used the code example that you provided but its not showing the data. In the code I changed
if (externalRecord.data.Email === record.data.Email) {
to
if (externalRecord.data.Name === record.data.Space) {
where Space is the name of the room name in the current DS and Name is the name of the room name in the external DS. Is this ok?
Also,
in
_.set(record, ‘data.CheckedIn’, foundEntry.data.CheckedIn);
I just wanted to double check, in the first “data.CheckedIn”, that CheckedIn is the name of the column from the external DS that I want to copy and add into the second foundEntry.data.CheckedIn that second CheckedIn which should match the column that you said to add the current DS as an empty column.

thanks!

Hi,

Yes that Name and Space change looks correct.

Regarding:
_.set(record, ‘data.CheckedIn’, foundEntry.data.CheckedIn);

‘data.CheckedIn’ = This should be the name of the empty column in the original DS. So it could be ‘data.Name’

foundEntry.data.CheckedIn = This should be the name of the column from the external DS. So it could be foundEntry.data.Space

Thanks,
Deb