Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Update Catalog Task Variable using REST API

rakshith_shetty
Tera Contributor

I am trying to update a sc task variable using patch api (/api/now/table/sc_task/<task_sys_id>)

Body-

{  
   "number": "SCTASK1502273",  
 "variables.risk_change1": "No",    
"variables.risk_assessment": "tEST ",    
  "work_notes": " testing"
 }
fields are updating but sc task variables are not getting updated.
Want to know like what is process for updating the variables using REST API.
can someone assist me ?
2 REPLIES 2

CezaryBasta
Tera Guru

I've never done that myself, but I am sure that you could achieve that with scripted REST APIs. The simple reason is that the variables on a SCTASK record are saved in another table - sc_item_variables_task. That is only the connection, no value there.

Because these variables are not actually connected directly with SCTASK, as they come from parent RITM, you also have to query sc_item_option_mtom to get/update the variable value.

 

--
See more of my content here.

Community Alums
Not applicable

Hi @rakshith_shetty ,

Please check below link this may help you

https://www.servicenow.com/community/developer-forum/cart-api/m-p/2023814

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak