Pergunta

I'm trying to get the properties of the subfolders using jsom. Let's say: name, url, etc

I'm using this:

...
var ctx = new SP.ClientContext(currentSite);
web = ctx.get_web();
list = web.getFolderByServerRelativeUrl(subfolderURL);

ctx.load(list,'Include(Name)');

And I'm getting the following error:

Invalid request

If I try to load the subfolder only:

ctx.load(list);  

I don't have the error but I'm not able to access the properties of the subfolder.

Am I doing something wrong?

Foi útil?

Solução

When you want to retrieve properties for a single item/folder/list/etc and not a collections of items/folders/lists/etc you need to specify properties like this:

ctx.load(list, 'Name', 'Url', 'other_property_here');

Basically, you DON'T use Include(), but specify the properties as comma-separated arguments in the ctx.load() function.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top