Comparing version 1.2.2 to 1.2.3
@@ -53,2 +53,42 @@ # @pnp/sp/fields | ||
## Filtering Fields | ||
Sometimes you only want a subset of fields from the collection. Below are some examples of using the filter operator with the fields collection. | ||
```TypeScript | ||
import { sp } from '@pnp/sp'; | ||
const list = sp.web.lists.getByTitle('Custom'); | ||
// Fields which can be updated | ||
const filter1 = `Hidden eq false and ReadOnlyField eq false`; | ||
list.fields.select('InternalName').filter(filter1).get().then(fields => { | ||
console.log(`Can be updated: ${fields.map(f => f.InternalName).join(', ')}`); | ||
// Title, ...Custom, ContentType, Attachments | ||
}); | ||
// Only custom field | ||
const filter2 = `Hidden eq false and CanBeDeleted eq true`; | ||
list.fields.select('InternalName').filter(filter2).get().then(fields => { | ||
console.log(`Custom fields: ${fields.map(f => f.InternalName).join(', ')}`); | ||
// ...Custom | ||
}); | ||
// Application specific fields | ||
const includeFields = [ 'Title', 'Author', 'Editor', 'Modified', 'Created' ]; | ||
const filter3 = `Hidden eq false and (ReadOnlyField eq false or (${ | ||
includeFields.map(field => `InternalName eq '${field}'`).join(' or ') | ||
}))`; | ||
list.fields.select('InternalName').filter(filter3).get().then(fields => { | ||
console.log(`Application specific: ${fields.map(f => f.InternalName).join(', ')}`); | ||
// Title, ...Custom, ContentType, Modified, Created, Author, Editor, Attachments | ||
}); | ||
// Fields in a view | ||
list.defaultView.fields.select('Items').get().then(f => { | ||
const fields = (f as any).Items.results || (f as any).Items; | ||
console.log(`Fields in a view: ${fields.join(', ')}`); | ||
}); | ||
``` | ||
## Add Fields | ||
@@ -55,0 +95,0 @@ |
{ | ||
"name": "@pnp/sp", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "pnp - provides a fluent api for working with SharePoint REST", | ||
@@ -11,5 +11,5 @@ "main": "./dist/sp.es5.umd.js", | ||
"peerDependencies": { | ||
"@pnp/common": "1.2.2", | ||
"@pnp/logging": "1.2.2", | ||
"@pnp/odata": "1.2.2" | ||
"@pnp/common": "1.2.3", | ||
"@pnp/logging": "1.2.3", | ||
"@pnp/odata": "1.2.3" | ||
}, | ||
@@ -16,0 +16,0 @@ "author": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5268279
44488