Field Value not updated

bhanukota09
Giga Contributor

I am trying to push a value into a field using a background script. After running the script, it shows that the field was modified, but the value is not updated in the field. Could you please review the code and let me know the solution?
it's showing KB updated successfully 

var gr = new GlideRecord('kb_knowledge');

if (gr.get('KBarticle sys_id')) {

    gr.setWorkflow(false);

    gr.setValue('taxonomy_topic', 'value sys_id ');

    gr.update();

    gs.info('KB updated successfully');

}

1 ACCEPTED SOLUTION

SumanthDosapati
Mega Sage

@bhanukota09 

No issue in the script. Make sure you are running the script in Global scope.

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

View solution in original post

4 REPLIES 4

TharaS657398130
Kilo Guru

Hi

Can you check the dictionary for taxonomy_topic? If its reference/related field then you must update the relationship table not the field.

Also in your 4th line of code there is an extra space..Can you check that too?

 

Ankur Bawiskar
Tera Patron

 

@bhanukota09 

are you able to update it from UI?

are you able to update it from list via Data Management?

are you giving correct sysId?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

SumanthDosapati
Mega Sage

@bhanukota09 

No issue in the script. Make sure you are running the script in Global scope.

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

Tanushree Maiti
Kilo Patron

Hi @bhanukota09 

 

In Order to update topic , you need  connecting a Knowledge article to a Taxonomy topic involves creating or updating a record in the m2m_connected_content table, which links content (Knowledge, Catalog Items, etc.) to the Unified Taxonomy.

 

Check the sample code from following post:

 

Refer: https://www.servicenow.com/community/developer-forum/insert-on-m2m-connected-content-doesnt-work/td-...

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: