I have reviewed my own posts that relate to the subject of Lookup fields, looked again at your Extra Fields documentation, and searched against other community posts that had keywords such as “Extra Fields“ and ”LookupDependent”. I have also tried various tests and it seems I have failed to recall this simple task of getting extra fields to update on change of the lookup field itself. It seems obvious but I can’t quite reach the goal.
LIST 1: Main list with Lookup column ‘referencesdemo’ which references ReferencesDemo (Source/List 2)
CODE ATTEMPTS: (there were many more but I am starting from scratch now)
//Ready 'referencesdemo' Lookup field > THIS WORKS
fd.spRendered(function() {
fd.field('referencesdemo').ready(field => {
alert('Your item is now ready for development.');
});
});
//Trying to update extra fields when 'referencesdemo' Lookup field changes > DOES NOT WORK
fd.spRendered(function() {
fd.field('referencesdemo').ready(function() {
fd.field('referencesdemo').$on('change', function(value) {
//core-book
fd.field('referencesdemo_x003a_core_x002d_').value = value.LookupValue;
fd.field('referencesdemo_x003a_core_x002d_0').value = value.LookupValue;
fd.field('referencesdemo_x003a_core_x002d_1').value = value.LookupValue;
fd.field('referencesdemo_x003a_core_x002d_2').value = value.LookupValue;
fd.field('referencesdemo_x003a_core_x002d_3').value = value.LookupValue;
fd.field('referencesdemo_x003a_core_x002d_4').value = value.LookupValue;
//journals
fd.field('referencesdemo_x003a_journal_x00').value = value.LookupValue;
fd.field('referencesdemo_x003a_journal_x000').value = value.LookupValue;
//website
fd.field('referencesdemo_x003a_website').value = value.LookupValue;
fd.field('referencesdemo_x003a_website_x00').value = value.LookupValue;
//ID
fd.field('referencesdemo_x003a_ID').value = value.LookupValue;
});
});
});
@Margo - your statement “Values of the additional columns will be displays only after the data is saved” in this post, and the link to more info when we “want to show this values instantly when user selects an option in a lookup dropdown”, I have also tried adding the extra fields but have had no luck. I will keep trying but it occurs to me - are Extra Fields those which are built-in SharePoint/EntraID fields, or so they also support those fields we create in SP?
Add code to populate the Common Text fields when the value of the Lookup field changes:
fd.spRendered(function() {
fd.field('referencesdemo').ready(field => {
field.$on('change', value => {
//populate common field with extra column value
fd.field('Text1').value = value.InetrnalNameExtraColumn
});
});
});
Replace InetrnalNameExtraColumn with the inetrnal name of the extra column.
Thank you as always @Margo . DO you sometimes roll your eyes and shake your head with these questions? I am sorry because I know the answers largely exist somewhere already; the large volume of posts and finding the right search term sometimes defeat my best efforts. I hope you are well and I thank you so much for taking the time to spell out all of the details - sometimes for the nth time
No, not really. It is okay to not understand something, and I'm here to explain. And when it comes to Lookups—it is pretty complex field and it trips me up sometimes too!
@Margo - I got it figured out, yes. Thank you so much.I have some filtering to do and also some UI design work ahead, but the functionality is on target. Thank you as always. When it is looking clean, I will upload a screen capture here and mark as solved