Displaying fields from a SharePoint lookup selection

I found a similar question from 2019 that said this wasn't possible at the time, but maybe things changed since then.

I have a submission form in a SharePoint Online list. That list has a SP Lookup column that links to another list on the site for different approval types, Low / Med / High priority and some other details associated with it. It would be great if a person filling out the original form could select the "Low" option from the lookup and then using JS, or some Plumsail magic, display specific fields from that lookup list as read only. Just enough to assist the person to know if they selected the correct lookup option.

I don't know if I can use the 'SP Lookup Field' control with the 'List or Library' control and filter it to display one item? When I try that, the 'List of Library' property named 'Lookup Field' is a dropdown with no options. Maybe I'm using it wrong.
image

Hello @pbehler,

Yes, you can filter List or Library control dynamically, but you will need a code for this. Please find the example in Filter List or Library by CAML in a SharePoint form article.

Thank you again. I got the filter to work using the value of the SP lookup column from the form. I'm guessing I can add the additional code to refresh the filter when someone updates the lookup field value.

//SPDataTable0 is name of the SPListLibrary Control
//PriorityLookup is the name of the SP lookup column


fd.spRendered(function() {
    var dt = fd.control('SPDataTable0');
    dt.ready(function() {
        filterDT();
    });

    function filterDT(){
        dt.filter = "<Eq><FieldRef Name='Priority'/><Value Type='Text'>" + fd.field('PriorityLookup').value.LookupValue + "</Value></Eq>";
        dt.refresh();
    }

});

Except now I think I needed to do something different because the ListLibrary control doesn't render the JSON formatted Card View when I select it from the "View" dropdown.

I think I need to learn more about the Extra Fields property or if there is a way to query another list using CAML and display certain fields in a text box.

Yes, you can call a function when field value changes to filter control dynamically, as shown in Filter by one field dynamically example.

I'm sorry, could you please share more details. Have you formatted the column in a SharePoint List view? Could you please share the screenshot?
Not all list formatters are supported by List or Library control, but you can add a custom column formatting to customize how columns in List or Library control are displayed.

You can list the fields you want to retrieve from the source list of the Lookup field in the Extra Fields property and then display it, for instance, in a common field using the code:

fd.field('CommonField').value = fd.field('LookupField').value.ExtraFieldName;

As an alternative, you can use the PnPjs library to get multiple values from the list. You can find some examples in our documentation: PnPjs Library — SharePoint forms