1
pnp.sp.web.lists.getByTitle("ListName").items.getById(1).update({
    Title: Title,
    DeptDiv://internal name of list column 
   {
      __metadata: 
     { 
         "type": "SP.Taxonomy.TaxonomyFieldValue" },
          Label: Department1,//value to be updated
          TermGuid: "**********************",
          WssId: -1,
     }
   }).then(r => {

    console.log(r);
});
2
  • is it a single value taxonomy field or multi-valued field ? The code seems to be fine and works for me in SPO, whats the error ? Jun 27, 2018 at 13:43
  • Getting the following Error:Failed to load resource: the server responded with a status of 400 () exceptions.js:24 Uncaught (in promise) Error: Error making HttpClient request in queryable: [400] at new ProcessHttpClientResponseException (exceptions.js:24) at core.js:37 Jun 28, 2018 at 5:25

1 Answer 1

2

You need to write the values for the fields in quotes.

Modify your code as below:

pnp.sp.web.lists.getByTitle("ListName").items.getById(1).update({
    Title: "Some title",
    DeptDiv: //internal name of list column 
   {
      __metadata: 
     { 
         "type": "SP.Taxonomy.TaxonomyFieldValue" },
          Label: "Department1", //value to be updated
          TermGuid: "**********************",  // guid of the term label(not termset)
          WssId: -1,
     }
   }).then(r => {

    console.log(r);
});
8
  • Department1 is a variable. Jun 28, 2018 at 6:36
  • it needs to be a string. Also, the term should exist in the term set. Try hard-coding a term label guid and label and check. Jun 28, 2018 at 6:51
  • TermGuid: its the termset unique identifier right? or the labels unique identifier. Taxonomy->Term Group->Department(Termset)->Term label. I am using the GUid if Termset. Jun 28, 2018 at 7:02
  • it should be the guid of the term inside the termset i.e term label ( Department(Termset)-> Term label ) --- guid of the Term label Jun 28, 2018 at 7:04
  • Getting the following Error:"Failed to load resource: the server responded with a status of 400 () exceptions.js:24 Uncaught (in promise) Error: Error making HttpClient request in queryable: [400] at new ProcessHttpClientResponseException (exceptions.js:24)" I have checked all the internal names are correct. Jun 28, 2018 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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