Pergunta

I am creating a folder inside a List with the following code:

TypeScript
import {sp} from "@pnp/sp";

const shpList = sp.site.rootWeb.lists.getById(ListId);

shpList.items.add(
{
  Title: folderName,
  FileSystemObjectType: 1,
  ContentTypeId: '0x0120',
  FileLeafRef: folderName,
  DisplayName: folderName
} )

And it does create the folder, but the navigation displays 130_.000 as the folder. (It's the item's ID plus underscore, dot and three zeros)

Is there a way to create the item so it uses the title as the navigation?

Is there any place I can look for the default properties of SharePoint?


Here a list of the properties I have already tested:

  • Name (and name) | value: folderName | result: error (not registered property)
  • FileRef | value: folderName | result: Does not seem to do anything
  • Path (and path) | value: folderName | result: error (not registered property)
  • Folder | value: folderName | result: error (primitive value not null)
  • Url (& url & URL) | value: folderName | result: error (not registered property)
Foi útil?

Solução

What worked for me is creating the folder then updating it with the right FileLeafRef like so:

let newFolder = {
        ContentTypeId: '0x0120',
        Title: folderName
      };


  shpList.items.add( newFolder )
          .then((value) =>
          {
            shpList.items.getById( value.data.Id )
            .update({FileLeafRef: folderName})
            .then(() =>
            {
              // The folder is not created as intented
            }
          } );
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top