List and Library rename the file on upload

Hello @shedev,

The code you've shared has incorrect lines.

This must be list id that you can get from the List Settings page URL:

var docLibraryId = 'Private';

This code is invalid:

var MediaFileTypeV = fd.field('MediaFileType').LookupValue.value;
    var BodySiteV = fd.field('BodySite').LookupValue.value;

To get the display value of the lookup field, you must use this code:

fd.field('Field1').value.LookupValue;

And you need to set the filename variable only once. Remove this line:

filename = uri.substring(uri.lastIndexOf("/")+1,uri.lastIndexOf(".")) + '_' + fileID;

Please see PnPjs documentation for more information and code examples.