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.

We have scripted rest API which gets the request from another API. we have to update this request in a field in a table. I am able to get the request details & i can see the request body by capturing in the logs but when i am trying to set the same b

krishna26
Kilo Expert

Hi Guys,

We have scripted rest API which gets the request from another API. we have to update this request in a field in a table. I am able to get the request details & i can see the request body by capturing in the logs but when i am trying to set the same body to the concerned field in the required table , i couldn't do so, it's empty. (pls see the screen shots for reference).

I need that request body to be updated to the particular field . Any help on this please ?

1 ACCEPTED SOLUTION

as discussed over hangout , we solved it with below line. 

 

var parser = new JSON();
var obj = parser.decode(ab);

 

 

View solution in original post

15 REPLIES 15

then you dont need to parse, you should access the json object directly. 

 

just confirming, in u_response_body_payload column its not updating the value ?

 

can you add this below line after line number 8, to validate if gliderecord is working fine or not. 

gs.log('Row count is '+inc_test.getRowCount());

Hi Harsh,

Looks like from the script , i can't set any value. For the sake of checking i glided an incident record & tried to update but it's not working.

There's is something wrong when we are using script for setting the field values

can you confirm , the row count of your first glide record ? like i had mentioned in my earlier response, put log to check the row count of your gliderecord. 

 

let me know the log details 

 

gs.log('Row count is '+inc_test.getRowCount());

 

i have put what you told & i am getting the row count but still no luck in updating the concerned record

just for testing , can you add log of those value which you are setting in the column. 

can you paste the script here . i will try to make it short for testing. 

also can you confirm any business rule is not contradicting here ?