Lookup Column | Additional Fields | Display Form

If our Form is for a Car, which has a lookup to an Owner
When configuring the Lookup column in SharePoint,
we chose the Title column from the Owner List
and chose Owner:Address as an 'Additional Column'

It is easy enough to display the Owner [Title] on the Display Form for the Car.
But how do we also display the Owner:Address field value on the Display Form for the Car?

NOTE: This is a one-to-one, directional relationship where one Car references one Owner (not parent/child, not bi-directional).

Hello @ShareSquared,

Additional fields are listed under SharePoint Fields in the left panel in the desktop designer.

image

You can either add it or use the approach from this post.

Thank you @mnikitina. I find that the 'Additional Columns' that I've included are not showing up in the list of SHAREPOINT FIELDS for my Form.

The Property:Number field is not available to me in the Form Designer :frowning:

Hello @ShareSquared,

I've tested it, and it works only if the management of content types is disabled.

Also, you can get values of extra fields by specifying their names in Lookup Settings >> Extra Fields.

image

and using this code:

fd.field('Lookup').value.FieldInternalName

You can find more information in Configure cascading lookups article and in this post.

Thank you, @mnikitina.

In our work, nearly all Lists and Libraries use custom content types. That is kind of why we need a custom Form :slight_smile:

I was able to get the Extra Fields to work, but found that I had to prepend Odata_ to the beginning of any field internal names that begin with underscore.

Internal Field Name: _MyField
Change to make it work in Extra Fields: Odata__MyField

Any idea on that one?

Hello @ShareSquared,

Extra field values are getting using Odata query. If the field name starts with an underscore, you need to add "OData_" to its internal name.

And to get the value, you need to use this code:

fd.field('Lookup').value.OData__MyFieldName
1 Like

While I have been able to get this to work on the New Form, it is not working on the Display Form.
I have added to the ExtraFields all of the field names from the looked-up list item but none of the data is coming back...

Hello @ShareSquared,

The extra fields are only available when the lookup control (dropdown) is opened - this is when the request is sent, and all data is returned.

My colleagues shared a trick on how to add additional fields of the lookup field to the content type and display them in the designer toolbox. You need to remove lookup field from the Content Type and add it back in. Additional fields will be added to the content type, and you can add them from the toolbox to the form.

image

Thanks, I will give that a try.

Is there any trick for bringing back field values of data types that cannot be configured as additional columns on the lookup?

For example, if the list that I am looking up to has a "Multiple lines of text column", SharePoint doesn't let me set that as an Additional Column when configuring the lookup. Is there a way (even with JavaScript) to get those other fields of the looked-up item onto the form?

Hello @ShareSquared,

Yes, you can get the values from the other list using PnPjs.

fd.spRendered(function() {

    pnp.sp.web.lists.getByTitle('ListName').items.select('Title').get().then(function(items) {
        // log the Title of the first record
        console.log(items[0].Title);
    });

});

Thanks, I'll try that.

1 Like

This works GREAT:

function updateChildItemInfo() {
console.log('// looking up ChildItem Info...');
// grab current value
var ChildItemID = fd.field('ChildItemLookup').value.LookupId;
pnp.sp.web.lists.getByTitle('ChildItems')
    .items.getById(ChildItemID)
    .get()
    .then(function(foundItem) {
        if (foundItem) {                             
            // fill out the form values
            fd.control('txtChildItemProperty1').text = foundItem.Column1;
            fd.control('txtChildItemProperty2').text = foundItem.Column2;
        }
    }); // DONE>ChildItem Value 1 and Value 2                      

}

2 Likes