Metadata for uploaded documents

@Sternchen,

What is the type of this portal? The URL is strange, it must be sites instead of groups.

Please try the code I've shared. Are you getting the same error?

I tried your code and I get this error.

Dear @Sternchen,
The URLs are in fact different in the console. Since your domain is not contoso, can you share the actual code that you've used?

Sure here it is:

var listOrLibrary = 'SPDataTable1';
var docLibraryId = '6487e86f-b9aa-472a-824d-7d2da7615032';
let web = new Web('https://collaboration.connect.buzziunicem.com/groups/00074/')

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

        var batch = web.createBatch();
        var currentName;
        var uri;


        for (var i = 0; i < itemIds.length; i++) {
            //specify which fields to update and how
            var itemId = itemIds[i];
            library.items.getById(itemId).select('FileRef', 'Id').get().then(function(item) {
                return item

            }).then(function(item) {
                uri = item.FileRef;
                var fileID = item.Id;
                filename = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf(".")) + "_" + fileID;
                var nbatch = web.createBatch();
                library.items.getById(fileID).inBatch(nbatch).update({
                    FileLeafRef: filename
                }, "*", entityTypeFullName)
                nbatch.execute().then(function() {
                    fd.control(listOrLibrary).refresh();
                });
            });
        }
    });
});

And I´m trying a different one. This code works but without the FileLeafref:filename.

fd.control(listOrLibrary).$on('filesUploaded',
function(itemIds) {
//get document library by Title
var library = pnp.sp.web.lists.getByTitle(docLibraryTitle);

            var batch = pnp.sp.web.createBatch();
            var currentName;
            var uri;

            for(var i = 0; i < itemIds.length; i++){
                //specify which fields to update and how
                var currentItem = pnp.sp.web.lists.getByTitle(docLibraryTitle).items.getById(itemIds[i]);
                uri= itemIds[i].FileLeafRef.value.BaseName;
                currentName= fd.field('FileLeafRef').value.BaseName;
                filename = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf(".")) + "_" + itemIds[i];
                currentItem.inBatch(batch).update({
                FileLeafRef: filename, Data: fd.field('Attachments_x0020_document_x0020').value, Description0: fd.field('Description').value
                });
                    
            }

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

Dear @Sternchen,
What happens if you try just this:

var docLibraryId = '6487e86f-b9aa-472a-824d-7d2da7615032';
let web = new Web('https://collaboration.connect.buzziunicem.com/groups/00074/')
var library = web.lists.getById(docLibraryId);
library.getListItemEntityTypeFullName().then(function(entityTypeFullName) {
  console.log(entityTypeFullName);
});

Any errors in the browser's console?

Here are the logs.

Dear @Sternchen,
Interesting that it says getByTitle in the error message. I would recommend contacting the professional pnpjs community with this specific request and why it fails, as this is a little beyond our expertise - Newest 'pnpjs' Questions - SharePoint Stack Exchange

I´ll try this. Thanks for the help.