This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
Working With: Related Items
Patrick Rodgers edited this page Apr 6, 2017
·
1 revision
Related items are used in Task and Workflow lists (as well as others) to track items that have relationships similar to database relationships. This functionality was added to the library as part of 2.0.3.
All methods chain off the Web's relatedItems property as shown below:
Expects the named library to exist within the contextual web.
pnp.sp.web.relatedItems.getRelatedItems("Documents", 1).then((result: RelatedItem[]) => {
console.log(result);
});
Expects the named library to exist within the contextual web.
pnp.sp.web.relatedItems.getPageOneRelatedItems("Documents", 1).then((result: RelatedItem[]) => {
console.log(result);
});
pnp.sp.web.relatedItems.addSingleLink("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite", "RelatedItemsList2", 1, "https://site.sharepoint.com/sites/dev").then(_ => {
// ... return is void
});
pnp.sp.web.relatedItems.addSingleLink("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite", "RelatedItemsList2", 1, "https://site.sharepoint.com/sites/dev", true).then(_ => {
// ... return is void
});
Adds a related item link from an item specified by list name and item id, to an item specified by url
pnp.sp.web.relatedItems.addSingleLinkToUrl("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite/Documents/test.txt").then(_ => {
// ... return is void
});
pnp.sp.web.relatedItems.addSingleLinkToUrl("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite/Documents/test.txt", true).then(_ => {
// ... return is void
});
Adds a related item link from an item specified by url, to an item specified by list name and item id
pnp.sp.web.relatedItems.addSingleLinkFromUrl("https://site.sharepoint.com/sites/dev/subsite/Documents/test.txt", "RelatedItemsList1", 2).then(_ => {
// ... return is void
});
pnp.sp.web.relatedItems.addSingleLinkFromUrl("https://site.sharepoint.com/sites/dev/subsite/Documents/test.txt", "RelatedItemsList1", 2, true).then(_ => {
// ... return is void
});
pnp.sp.web.relatedItems.deleteSingleLink("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite", "RelatedItemsList2", 1, "https://site.sharepoint.com/sites/dev").then(_ => {
// ... return is void
});
pnp.sp.web.relatedItems.deleteSingleLink("RelatedItemsList1", 2, "https://site.sharepoint.com/sites/dev/subsite", "RelatedItemsList2", 1, "https://site.sharepoint.com/sites/dev", true).then(_ => {
// ... return is void
});
Sharing is caring!