5

I am new to to Typescript, watched videos and created the sample application of client webpart using new SharePoint development framework. All sample application worked well, and using Rest Queries i was able to do some of the List operation.but now my current Project Requirement, to get the termsets values from Taxonomy and as i aware there is no Rest end points available for Termset yet.(let me know if its available.)

I followed https://github.com/gandjustas/sptypescript , for some sample to help for my requirement but with no luck yet.

followed this blog http://thecollaborationcorner.com/2016/08/31/part-4-the-navigation-implementation/#.WD622YVOKM8 . even this is specific to Navigation Termset.

Could anybody help on this, how i can get the Taxonomy termset values using new SharePoint framework.

4

There is a sample for Taxonomy in sp-dev-fx-webparts. Following things you can get from this sample

  • Reading taxonomy term stores' hierarchy from SharePoint
  • Loading JavaScript Object Model scripts
  • creating Knockout components

I believe you can get help from this file to get term Termset.

  • This is giving me error, and not working on IE,anyone faced the same issue? – Ashutosh Nov 21 '18 at 11:30
1

You can use @pnp/sp-taxonomy/terms.

Install with:

npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp @pnp/sp-taxonomy @pnp/sp-clientsvc -- save

Import:

import { Session } from '@pnp/sp-taxonomy';

Usage:

const taxonomy = new Session(siteCollectionURL);
const store: any = taxonomy.termStores.getByName(termStoreName);
store.getTermSetById(termsetId).terms.select('Name', 'Id', 'Parent').get()
.then((data: any[]) => {
  console.log(data)
})

Docs: https://github.com/pnp/pnpjs/blob/dev/packages/sp-taxonomy/docs/terms.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.