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);
});
  • 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 ? – Gautam Sheth Jun 27 '18 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 – Vaishali Udupa Jun 28 '18 at 5:25
1

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);
});
  • Department1 is a variable. – Vaishali Udupa Jun 28 '18 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. – Gautam Sheth Jun 28 '18 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. – Vaishali Udupa Jun 28 '18 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 – Gautam Sheth Jun 28 '18 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. – Vaishali Udupa Jun 28 '18 at 9:04

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.