Problem setting Library field values

Hi, I have been following theese 2 tutorials for implementing Cascading dropdowns & Update uploaded files and it works as expected, until it comes to setting Lookup fields manually.

I am fetching selected "Disciplin" value and try to send it Library fileUpload in picture below.
No matter how I try to update the Library it wont work for Lookup fileds. Selected item value is not sent to Library below.
It works fine for regular Text input fields but not for Lookup fields.
I have tried everything i found on this forum without any success,

  var listOrLibrary = 'SPDataTable0';
  var docLibraryTitle = 'DevTest';

  fd.control(listOrLibrary).$on('filesUploaded',
    function(itemIds) {
        //get document library by Title
        var library = pnp.sp.web.lists.getByTitle(docLibraryTitle);
        //go through each uploaded Item Id and set field values
        library.getListItemEntityTypeFullName().then(function(entityTypeFullName){

            var batch = pnp.sp.web.createBatch();
            for(var i = 0; i < itemIds.length; i++){
                //specify which fields to update and how
                library.items.getById(itemIds[i]).inBatch(batch).update({
  		Disciplin: fd.field('Disciplin').value   //<<< Field value is not added to Library!! 
                }, "*", entityTypeFullName);
            }

            batch.execute().then(function(){
                fd.control(listOrLibrary).refresh();
            });
        });
    });

Hi mate, saw this and thought it was a quick one, appreciate you want the Plumsail team to look but hopefully it’s a quick fix.

If you are setting a lookup field in the listorLibrary control, where you are getting the Lookup ‘value’ the field should read:

fd.field(‘Disciplin’).value.LookupId

This is because the Lookup field is an object containing the ‘value’ (which is the text in the field) and the ‘Id’ which is the value you would use to set the field.

If the destination field is text use .LookupValue instead of .LookupId

At least I think that’s whats going wrong. Hope this helps.

1 Like

Hi, Thank you for nice explanation, its working fine now.
Regards //