Get fields values from parent folder

good day !
i have a list. i created some folders in it. on quick edit put some fields values at folder.
Now i open 1 folder and create new item. how can i get values from this parent folder? like folder name, and 1-2 fields values?
Folders


items in folder

i need to get cod from folder and name folder in creating new item.

Dear @ixxxl,
What Content Type are you using to create New items inside a folder? Are you using a New Form to add these items?

Retrieving the folder is possible with pnpjs - Folders - PnP/PnPjs

@Nikita_Kurguzov
it is Element, i -am using new form to add these items.
i tried this one

// list's folder
const listRootFolder = await sp.web.lists.getByTitle("234").rootFolder();

// item's folder
const itemFolder = await sp.web.lists.getByTitle("234").items.getById(1).folder();

and i think a need itemFolder, but on New form it didn't have ID. something doesn't work for me...

@Nikita_Kurguzov
Can you, please, verify in your environment?

Dear @ixxxl,
Not sure what information you want to get, but here's what you can do:

var list = pnp.sp.web.lists.getByTitle("Documents");
list.rootFolder.folders.get().then(function(folders){ 
    for(var i = 0; i < folders.length; i++){
        var folder = folders[i];
        if(folder.ServerRelativeUrl == fd.rootFolder){
            console.log(folder);
        }
    }
});

@Nikita_Kurguzov
good day,
i need 2 fields name folder, and COD of department, which are stored in folder.


another user , from main office, will create in this folder some simple items. and to not write manual cod department, i would like to take it from the folder.
create item in folder:

and on new item to populate 2 fielnds title folder ,and cod of department (stored in folder). This i need to put this cod in field group, to make AD groups to grant permissions on future list and library items , and to notify them.

p..s. name of folder i can achieve with your shared code, folder.Name.
how can i get folder.Cod_Sucursala? thank you

Dear @ixxxl,
You can get all properties of the folder like this, use Internal Name of the column instead of MyCode:

pnp.sp.web.getFolderByServerRelativePath(fd.rootFolder).properties().then(function(folder){
  console.log(folder.MyCode);
});

You can check Internal Name of the Cod Sucursala column in Library settings > Column settings URL:

@Nikita_Kurguzov
have an error:

fd.spRendered(function () {
      function group() {

        var list = pnp.sp.web.lists.getByTitle("Proiecte Salariale");
        list.rootFolder.folders.get().then(function (folders) {

            for (var i = 0; i < folders.length; i++) {
              var folder = folders[i];
              console.log(fd.rootFolder)
              if (folder.ServerRelativeUrl === fd.rootFolder) {
                console.log(folder);
                console.log(folder.Name);
                console.log(folder.ServerRelativeUrl);

                pnp.sp.web.getFolderByServerRelativePath(fd.rootFolder).properties().then(function (f) {
                  console.log(f)
                  console.log(f.Cod_x0020_Sucursala);
                });

              }
            }

          });

      }
        group();

      });

Dear @ixxxl,
Just tested it in the SharePoint 2019, you don't need all the code, just the part above:

fd.field('FileLeafRef') is the Name field, and the Test ABC is the value retrieved:

What's the version of Plumsail Forms app you're running?

@Nikita_Kurguzov
1.4.8

Dear @ixxxl,
You might need to update the solution to get the latest functionality - Update Plumsail Forms On-Premises solution — SharePoint forms

@Nikita_Kurguzov
thank you.
can i have some problems after update in my old forms ?

Dear @ixxxl,
This shouldn't be the case, but it's always to have some down time to do some quick tests. Make sure to follow all the steps in the instruction and update both Server side solution as well as the app package in the app catalog.