- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 07:37 AM - edited ‎02-01-2024 07:54 AM
Hello,
I am currently working on integrating ServiceNow with Asana. The purpose of this endeavor is to create a new project in Asana every time a new record is generated in ServiceNow. After successfully configuring the REST message, I am able to view the necessary values in the response body. However, I am now seeking assistance with the process of extracting the project ID (gid) from the response body and subsequently inserting it into the newly created record.
Response: "gid":"1206496649022055","resource_type":"project"
responseBody{"data":{"gid":"1206496649022055","resource_type":"project","created_at":"2024-02-01T15:06:15.348Z","modified_at":"2024-02-01T15:06:16.039Z","members":[{"gid":"1203482360254605","resource_type":"user","name":""}],"owner":{"gid":"1203482360254605","resource_type":"user","name":""},"due_date":"2020-04-30","due_on":"2020-04-30","public":false,"name":"testing chargeback",
Business rule:
(function executeRule(current, previous /*null when async*/) {
var request = new sn_ws.RESTMessageV2 ('Asana Create Project', 'Create Project');
request.setStringParameterNoEscape('u_team_id', current.getValue('u_team_id'));
request.setStringParameterNoEscape('u_project_name', current.getValue('u_project_name'));
var response = request.execute();
var responseBody = response.getBody();
var statuscode = response.getStatusCode();
var errorMsg = response.getErrorMessage();
gs.info("responseBody"+responseBody);
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 08:32 AM
It looks like a JSON formatted string so you should be able to just do this
var myvar = JSON.parse(responseBody);
//Then access things like this
myvar.data.grid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 08:32 AM
It looks like a JSON formatted string so you should be able to just do this
var myvar = JSON.parse(responseBody);
//Then access things like this
myvar.data.grid